What's the meaning of the following code?
-
Hi all: I am trying to write data back to the Access Database. The following method seems to work well. But I don't understand what the following piece of code exactly work.
public static void WriteToDatabase(string tableName) { System.Data.OleDb.OleDbDataAdapter databaseAdapter = new OleDbDataAdapter("Select * from "+tableName, conn); new OleDbCommandBuilder(databaseAdapter); try { databaseAdapter.Update(ds, tableName); ds.Tables[tableName].AcceptChanges(); MessageBox.Show("Congratulations"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Could anybody explain it to me please? Or maybe you can give me a better way to write data back to access database please? Thank you very muchAsura
-
Hi all: I am trying to write data back to the Access Database. The following method seems to work well. But I don't understand what the following piece of code exactly work.
public static void WriteToDatabase(string tableName) { System.Data.OleDb.OleDbDataAdapter databaseAdapter = new OleDbDataAdapter("Select * from "+tableName, conn); new OleDbCommandBuilder(databaseAdapter); try { databaseAdapter.Update(ds, tableName); ds.Tables[tableName].AcceptChanges(); MessageBox.Show("Congratulations"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Could anybody explain it to me please? Or maybe you can give me a better way to write data back to access database please? Thank you very muchAsura
hi i think what are you missing is what the OleDbCommandBuilder dose !! its define the sql commands from a specific adapter
Tamimi - Code