title: How to check whether a SQL query is successful with C#
body: <p>I am new to C# and SQL. Now from a form I access a function in a class.</p>
  
  <p>My code is</p>
  
  <pre><code>public void updateSupplierInformation(string id, string name, string balance, string place, string address, string phone, string bankname, string bankbranch, string accountno)
  {
          if (conn.State == ConnectionState.Closed)
          {
              conn.Open();
          }
  
          SqlCommand NewCmd = conn.CreateCommand();
          NewCmd.Connection = conn;
          NewCmd.CommandType = CommandType.Text;
          NewCmd.CommandText = " update supplier set " + " ID = " + "'" + id + "'" + " , NAME = " + "'" + name + "'" + " , BALANCE = " + "'" + balance + "'" + " , PLACE = " + "'" + place + "'" + "  , LOCATION = " + "'" + address + "'" + ",  PHONE = " + "'" + phone + "'" + " , BANK_NAME = " + "'" + bankname + "'" + " , BANK_BRANCH = " + "'" + bankbranch + "'" + ", ACCOUNT_NO = " + "'" + accountno + "'" + " where ID = " + "@id";
          NewCmd.Parameters.AddWithValue("@id",id);
          NewCmd.ExecuteNonQuery(); 
          conn.Close();
      }
  </code></pre>
  
  <p>Now if a record doesn't exist in the database with the given <code>id</code> the application stops immediately. How can I handle this? I want to show a message that the data entered is wrong and ask the user to enter another data  </p>