Reputation: 111
I am hitting an Oracle database using C# and OleDb, I have sucessfully pulled data from a query but I am unable to update the database using OleDbAdapter.Update()
, my update code is below. ("Adapter" is a reference to the OleDbAdapter
object used to sucessfully pull data out of the database.)
OleDbCommandBuilder builder = new OleDbCommandBuilder(Adapter);
Adapter.UpdateCommand = builder.GetUpdateCommand();
Adapter.UpdateCommand.Prepare();
Adapter.Update(ds);
ds.AcceptChanges();
I am currently getting a "Command was not prepared." error on the first line of the above code. Any suggestions and I would be very grateful.
(Edit: ds is the DataSet)
Upvotes: 2
Views: 4034
Reputation: 52270
your version is not working because you query a stored procedure.
If you think of it: to work it needs all the information like keys and so on. What if you join tables in your stored procedure and select only a subset of rows without some important primary-keys?
In those cases you might need to write/get a stored procedure or query yourself and give it to the adapter.
Upvotes: 2