OleDbCommands and OleDbDataAdapter
-
i have some problems storing data in an access-database. my dataadapter don't want to execute the update()-command correctly. i'm creating my commands via OleDbCommandBuilder and the sql-statements seems correct. only the select-command works properly. the only difference between the select-command object and the others is a private attribute called "executequery". in the select-command that flag is true in the others false. but i cannot access it! what is to do? here's some code: string sConnString = "provider=Microsoft.JET.OLEDB.4.0; data source = myDatabase.mdb"; string sCmdString = "SELECT * FROM dbTest"; OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sCmdString, sConnString); OleDbCommandBuilder cb = new OleDbCommandBuilder(dataAdapter); dataAdapter.UpdateCommand = cb.GetUpdateCommand(); dataAdapter.UpdateCommand.CommandTimeout = 20; dataAdapter.InsertCommand = cb.GetInsertCommand(); dataAdapter.InsertCommand.CommandTimeout = 20; dataAdapter.DeleteCommand = cb.GetDeleteCommand(); dataAdapter.DeleteCommand.CommandTimeout = 20; // that works table = new DataTable(sTable); dataAdapter.Fill(table); // fill the table with some data // ... // that one doesn't work dataAdapter.Update(table); thanks, phil
-
i have some problems storing data in an access-database. my dataadapter don't want to execute the update()-command correctly. i'm creating my commands via OleDbCommandBuilder and the sql-statements seems correct. only the select-command works properly. the only difference between the select-command object and the others is a private attribute called "executequery". in the select-command that flag is true in the others false. but i cannot access it! what is to do? here's some code: string sConnString = "provider=Microsoft.JET.OLEDB.4.0; data source = myDatabase.mdb"; string sCmdString = "SELECT * FROM dbTest"; OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sCmdString, sConnString); OleDbCommandBuilder cb = new OleDbCommandBuilder(dataAdapter); dataAdapter.UpdateCommand = cb.GetUpdateCommand(); dataAdapter.UpdateCommand.CommandTimeout = 20; dataAdapter.InsertCommand = cb.GetInsertCommand(); dataAdapter.InsertCommand.CommandTimeout = 20; dataAdapter.DeleteCommand = cb.GetDeleteCommand(); dataAdapter.DeleteCommand.CommandTimeout = 20; // that works table = new DataTable(sTable); dataAdapter.Fill(table); // fill the table with some data // ... // that one doesn't work dataAdapter.Update(table); thanks, phil