none
Declare reference to TABLEadapter, not DATAadapter. RRS feed

  • Question

  • Hello all:

     

    The scoop: Windows Forms app. C# .Net V2.0. I have created a custom datepicker control.

     

    I want the control to be able to push changes to a strongly-typed dataset, then from the DataSet to the database. This dataset uses TableAdapters to do its UPDATE work. It was my intention to push a local reference to the TableAdapter into the control so that the control could then call that TA’s .Update() method.

     

    BUT - and there’s always a but – I can’t declare a class member as type TableAdapter. It’s not a choice. The closest I come is being able to declare a DataAdapter type locally, but then there seems to be no way to set the local DA = TA. I also can’t convert between the two.

     

    Is it because TableAdapters are under a "shifting" namespace made up of the DataSet name + the TableAdapter name?

    What do I do if I want to use TableAdapters to work with my DataSet but can’t declare references to them to be pushed to my control?

     

    Thanks

     

    Kurt

    Wednesday, May 21, 2008 8:44 PM

Answers

  • It is because there is no TableAdapter type in .NET. It sounds confusing, but TableAdapter actually refers to strongly typed wrapper (custom class) around DataAdapter. Basically TableAdapter is just another custom class (as any other one), but it is automatically generated for you by the Visual Studio .NET to save some time and simplify task, but it has its own custom class name. If this class name is consistent in your specific case than you could use it as parameter type to pass reference to your TableAdapter.

     

    Friday, May 23, 2008 5:37 PM
    Moderator

All replies

  • It is because there is no TableAdapter type in .NET. It sounds confusing, but TableAdapter actually refers to strongly typed wrapper (custom class) around DataAdapter. Basically TableAdapter is just another custom class (as any other one), but it is automatically generated for you by the Visual Studio .NET to save some time and simplify task, but it has its own custom class name. If this class name is consistent in your specific case than you could use it as parameter type to pass reference to your TableAdapter.

     

    Friday, May 23, 2008 5:37 PM
    Moderator
  •  

    Thanks Val:

     

    Sadly, no, it's not consistent in my app. I have since gotten around that by writing a generic Interface that defines an Update() method and inhertiting my TableAdapters from that. So far, so good.

     

    Thanks

    Friday, May 23, 2008 6:06 PM