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 theDataAdapter:But since your query “joins” two tables it may not be so easy. It may be possible if you turn your
SELECTquery into a proper join:Some other alternatives:
dataAdapter‘sUpdateStatementMore info from MSDN:
http://msdn.microsoft.com/en-us/library/xzb1zw3x(v=vs.80).aspx