title: How to update only A particular field(other fields should remain same) in access Database with c# form App
body: <p>I Am working on A form app in c# 
  in which there is An table where i was updating same data regularly
  in my db there is a table named customers has following columns</p>
  
  <p>CustomerId | Balance   |   Last_Bill_Id   |   Last_Bill_Date  |  Last_Bill_Total   |   Last_Deposited   |   Last_Deposited_Date    |    </p>
  
  <p>right now i'm using this 
  code to update my db</p>
  
  <pre><code> try
          {
  
              OleDbConnection con = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = G:\\my Documents\\Visual Studio 2008\\Projects\\xml_and_db_test\\xml_and_db_test\\bin\\Debug\\database_for_kissan_Pashu_AhaR_Bills.mdb");
           string queryText = "UPDATE Customers SET Balance = ? ,Last_Bill_Id = ?,Last_Bill_Date = ? ,Last_Bill_Total = ?,Last_Deposited = ? , Last_Deposited_Date =?  where CustomerId = ?;";
  
  
              OleDbCommand cmd = new OleDbCommand(queryText, con);
              cmd.CommandType = CommandType.Text;
  
  
  
  
  
  
  
              cmd.Parameters.Add("Balance", OleDbType.Integer).Value = Convert.ToInt32(textBox2.Text);
  
              cmd.Parameters.Add("Last_Bill_Id", OleDbType.Integer).Value = 15;
              cmd.Parameters.Add("Last_Bill_Date", OleDbType.Date).Value = DateTime.Now;
              cmd.Parameters.Add("Last_Bill_Total", OleDbType.Integer).Value = 1560;
  
              cmd.Parameters.Add("Last_Deposited", OleDbType.Integer).Value = 500;
  
              cmd.Parameters.Add("Last_Deposited_Date", OleDbType.Date).Value = DateTime.Now;
  
  
  
              cmd.Parameters.Add("CustomerId", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
  
  
  
  
  
              con.Open(); // open the connection
              //OleDbDataReader dr = cmd.ExecuteNonQuery();
  
              int yy = cmd.ExecuteNonQuery();
  
              textBox3.Text = "update Done";
              con.Close();
  
          }
          catch (Exception ex)
          {
              string c = ex.ToString();
              MessageBox.Show(c);
  
          }
  </code></pre>
  
  <p><strong>Problem</strong>
  Some time i don't wants to update <strong>Last_Deposited  And Last_Deposited_Date</strong>  fields then 
  i have tried this code</p>
  
  <pre><code>  try
          {
  
              OleDbConnection con = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = G:\\my Documents\\Visual Studio 2008\\Projects\\xml_and_db_test\\xml_and_db_test\\bin\\Debug\\database_for_kissan_Pashu_AhaR_Bills.mdb");
  
  
              string queryText = "UPDATE Customers SET Balance = ? ,Last_Bill_Id = ?,Last_Bill_Date = ? ,Last_Bill_Total = ?  where CustomerId = ?;";
  
              OleDbCommand cmd = new OleDbCommand(queryText, con);
              cmd.CommandType = CommandType.Text;
  
  
  
  
  
  
  
              cmd.Parameters.Add("Balance", OleDbType.Integer).Value = Convert.ToInt32(textBox2.Text);
  
              cmd.Parameters.Add("Last_Bill_Id", OleDbType.Integer).Value = 15;
              cmd.Parameters.Add("Last_Bill_Date", OleDbType.Date).Value = DateTime.Now;
              cmd.Parameters.Add("Last_Bill_Total", OleDbType.Integer).Value = 1560;
  
          //    cmd.Parameters.Add("Last_Deposited", OleDbType.Integer).Value = 500;
  
         //     cmd.Parameters.Add("Last_Deposited_Date", OleDbType.Date).Value = DateTime.Now;
  
  
  
              cmd.Parameters.Add("CustomerId", OleDbType.Integer).Value = Convert.ToInt32(textBox1.Text);
  
  
  
  
  
              con.Open(); // open the connection
              //OleDbDataReader dr = cmd.ExecuteNonQuery();
  
              int yy = cmd.ExecuteNonQuery();
  
              textBox3.Text = "update Done";
              con.Close();
  
          }
          catch (Exception ex)
          {
              string c = ex.ToString();
              MessageBox.Show(c);
  
          }
  </code></pre>
  
  <p>now whenever i'm updating my dB with second code the values saved in Last_Deposited And Last_Deposited_Date  are being deleted i don't wants to remove these values only wants to update when new values are available for these fields.</p>