Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Want to use OleDbCommandBuilder with IDbDataAdapter

Want to use OleDbCommandBuilder with IDbDataAdapter

Scheduled Pinned Locked Moved Database
databasewpfwcfhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alomgir Miah
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • A Alomgir Miah

      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

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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 an OleDbDataAdapter. You have an IDbDataAdapter reference to a concrete type, i.e. something that inherits from IDbDataAdapter. Alomgir Miah wrote: The restriction is that I cannot create instances of OleDbDataAdaper To create OleDbDataAdapter objects you need to place a     using System.Data.OleDb; line at the top of the file. The documentation for the OleDbDataAdapter class[^] says this. Quite probably you already have an OleDbDataAdapter that your are referencing through the IDbDataAdapter interface. If this is the case all you need to do is cast it to an OleDbDataAdapter 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?


      Do you want to know more?


      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups