I have a method that queries an audeb database and returns results in the data grid view. Now I want to update the database using the same data grid view. When I change the results in the data grid view and click on the update button, it should be updated in the database. I searched the code for this and the codes I am getting are not working. My visual method and update method are below. Please help me with this update code.
Private Zero btnViewSaleView_Click (Object Sender, EventArgs E) {String sql = "Select from Business * where billNumber =" (?); Ondebee Comand Com = new OLEDB Commands (SQL, Connection); Com.Parameters.AddWithValue ("@ P1", txtViewSaleBillNumber.Text); String textview stringing; Connection.Open (); OleDbDataReader res = com.ExecuteReader (); If (res.Read ()) {textViewSaleStringTemp = res ["salesRepNumber"] ToString (); TxtViewSaleSalesRepNumber.Text = textViewSaleStringTemp; TextViewSaleStringTemp = res ["Customer"]. ToString (); TxtViewSaleCustomer.Text = textViewSaleStringTemp; TextViewSaleStringTemp = res ["Cash Received"] ToString (); TxtViewSaleCashReceived.Text = textViewSaleStringTemp; TextViewSaleStringTemp = res ["Payment end date"]. ToString (); TxtViewSalePaymentCompletedDate.Text = textViewSaleStringTemp; } OleDbDataAdapter ada = New OleDbDataAdapter (); String sqlDGV = "Select from BillItem * where billNumber = (?)"; Ondebee Comand Commodigy = new Oleadby Commands (SKLDGV, Connection); Eda. Selection Commands = comDGV; ComDGV.Parameters.AddWithValue ("@ P1", txtViewSaleBillNumber.Text); Datatable t = new datatile (); Ada.fill (t); DGVViewSale.DataSource = T; Connection.Close (); } Private Zero btnViewSaleUpdate_Click (Object Sender, EventArgs e) {OleDbCommandBuilder cmb = new OleDbCommandBuilder (ADA); Ada.Update (t); // but this command does not recognize data adapters and data tables}
No comments:
Post a Comment