I retrieve data from database like this:
OleDbDataAdapter dataAdapter
= new OleDbDataAdapter("SELECT * "
+ " FROM myTab1, myTab2"
+ " WHERE myTab1.col1 = myTab2.col3"
, connection);//OleDbConnection connection = new OleDbConnection();
DataTable dataTable = new DataTable("myDataTable");
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = dataTable;
dataAdapter.Fill(dataTable);
Then I use bindingSource in order to access the data in my program, everything works perfect. But after all changes I've made in bindingSource, I need so save them into the database. How can I do this?
Well normally you'd call Update() on the DataAdapter:
dataAdapter.Update(dataTable);
But since your query "joins" two tables it may not be so easy. It may be possible if you turn your SELECT query into a proper join:
"SELECT * "
+ "FROM myTab1 "
+ "JOIN myTab2 ON myTab1.col1 = myTab2.col3"
Some other alternatives:
dataAdapter's UpdateStatementMore info from MSDN:
http://msdn.microsoft.com/en-us/library/xzb1zw3x(v=vs.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With