title: How to update Access database using a datagridview in C#
body: <p>I have a <code>datagridview</code> that bind with a <code>datatable</code> and using <code>DataPropertyName</code> the <code>datagridview</code> only shows 4 columns of <code>database</code>.<br>
  this is how I bind <code>database</code> to a <code>datagridview</code>:</p>
  
  <pre><code>string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings
  ["FeedLibraryConnectionString"].ConnectionString;
  OleDbConnection Connection = new OleDbConnection(StrCon);
  OleDbDataAdapter DataA = new OleDbDataAdapter("Select * from SelectedFeeds", Connection);
  DataTable DTable = new DataTable();
  DataA.Fill(DTable);
  
  frm.RationFeedsdataGridView.AutoGenerateColumns = false;
  
  frm.RationFeedsdataGridView.Columns[1].Name = "نام خوراک";
  frm.RationFeedsdataGridView.Columns[1].HeaderText = "نام خوراک";
  frm.RationFeedsdataGridView.Columns[1].DataPropertyName = "Feed Name / Description";
  
  frm.RationFeedsdataGridView.Columns[2].Name = "مقدار (کیلوگرم)";
  frm.RationFeedsdataGridView.Columns[2].HeaderText = "مقدار (کیلوگرم)";
  frm.RationFeedsdataGridView.Columns[2].DataPropertyName = "Quantity";
  
  frm.RationFeedsdataGridView.Columns[3].Name = "درصد (خوراک)";
  frm.RationFeedsdataGridView.Columns[3].HeaderText = "درصد (خوراک)";
  frm.RationFeedsdataGridView.Columns[3].DataPropertyName = "Percent";
  
  frm.RationFeedsdataGridView.DataSource = DTable;
  </code></pre>
  
  <p>So far nothing wrong,</p>
  
  <p>now I want when user change the value of <code>Columns[2]</code>, it's value automatically inserted (and after that updated) into <code>database</code> I tryed myself using this code but seems that it's wrong, the code is:</p>
  
  <pre><code>string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings
  ["FeedLibraryConnectionString"].ConnectionString;
  OleDbConnection Connection = new OleDbConnection(StrCon);
  OleDbCommand Cmd = new OleDbCommand();
  Cmd.Connection = Connection;
  double Quantity = Convert.ToDouble(frm.RationFeedsdataGridView.CurrentCell.Value);
  string FeedName = frm.RationFeedsdataGridView.CurrentRow.Cells[1].Value.ToString();
  Connection.Open();
  Cmd.CommandText="Update SelectedFeeds set Quantity=" +Quantity  'Where Feed Name / Description'= FeedName;
  Cmd.ExecuteNonQuery();
  Connection.Close();
  </code></pre>
  
  <p>the first problem is that my CommandText is wrong and I don't know how to fix it.
  what should I do?</p>