Want to use OleDbCommandBuilder with IDbDataAdapter
-
Hi, I am binding a DataTable to a DataGrid. To push the changes from DataTable to the actual database I need to use OleDbCommandBuilder. I have an instance of IDbDataAdapter. The restriction is that I cannot create instances of OleDbDataAdaper. Also OleDbCommandBuilder constructor does not accept IDbDataAdapter as a parameter. Is there a workaround. Help is appreciated. Thanks and Regards, Alomgir
-
Hi, I am binding a DataTable to a DataGrid. To push the changes from DataTable to the actual database I need to use OleDbCommandBuilder. I have an instance of IDbDataAdapter. The restriction is that I cannot create instances of OleDbDataAdaper. Also OleDbCommandBuilder constructor does not accept IDbDataAdapter as a parameter. Is there a workaround. Help is appreciated. Thanks and Regards, Alomgir
Alomgir Miah wrote: I have an instance of IDbDataAdapter This is being pedantic, but you don't have an instance of
IDbDataAdapter
. That is an interface and you cannot instantiate interfaces or abstract classes, you can only instantiate concrete types like anOleDbDataAdapter
. You have anIDbDataAdapter
reference to a concrete type, i.e. something that inherits fromIDbDataAdapter
. Alomgir Miah wrote: The restriction is that I cannot create instances of OleDbDataAdaper To createOleDbDataAdapter
objects you need to place ausing System.Data.OleDb;
line at the top of the file. The documentation for the OleDbDataAdapter class[^] says this. Quite probably you already have anOleDbDataAdapter
that your are referencing through theIDbDataAdapter
interface. If this is the case all you need to do is cast it to anOleDbDataAdapter
in order to use it. You do that like this:(OleDbDataAdapter)myIDbDataAdapterReference
Finally, and this is because it is a pet hate of mine, don't use command builders. They give false hope, and they hide from you what is actually going on. For more information, read this excellent article: Weaning Developers from the Command Builder[^] Does this help?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.