i have datagridview that connect to my database (access)
if i stay on any cell and change the value, a see that the value is changed
but when i make refresh i see that the value is back to the original value.
how i can update this cell (without sql query)
i bind dataset to datagridview like this:
dsView = new DataSet();
adp = new OleDbDataAdapter("SELECT * FROM Items", Conn);
adp.Fill(dsView, "Items");
this.dataGridView1.DataSource = dsView.Tables["Items"].DefaultView;
adp.Dispose();
please, i must find how to do it…..
thank’s in advance
If your datagridview is connected to the database and you do not want to use SQL, i can suppose it is bound to a datasource. If you performed that through the Visual Studio Designer there should be a
TableAdapter(if automatically generated, probably called YOURTABLENAMETableAdapter) and aBindingSource(if automatically generated, probably called YOURTABLENAMEBidingSource).To update your database you will have to call BindingSource.EndEdit() and then TableAdapter.Update(). After you have done this, you can refresh your data.
EDIT
Now that you have provided better information i can give you a better answer.
In my previous answer, I assumed that you created everything with the designer because you didn’t want to use SQL to make the update. Obviously i was wrong.
To achieve what you are looking for, you should use the
OleDbCommandBuilderClass which, given aSELECTcommand, automatically generates simple editing command (insert/update/delete) for your table.here is an example using your code:
Now, after you perfomed your changes to the data you can call