none
Cannot Modify Dataset RRS feed

  • Question

  • I've got an existing project that has a form with bound controls to a dataset xsd.  The xsd has probably 12 queries (stored procedures) drug to the designer surface I suppose and dropped on the dataset designer surface. One of those is a SP that return items data.  I've had to add a column on the database and have modified the stored procedure that was originally dropped onto the XSD designer service.  We have several databases all wit the same tables etc. I'm probably not hitting the same database as this original design but all the table names and stored procedures are the same.  I just need to "refresh" the XSD to show my additional field and also point this to the correct connection string.
    Problem is is using a base table adapter that all it does is create a data connection at run time - so at design it doesn't even know this component exists.  I get a Type 'BaseTableAdapter' is not defined error for each time the

     

    Inherits Global.BaseTableAdapter

    which the generated code produced is referenced.  Argh!!

    If i pull this out of source code again to get it to work.....but everytime I attempt to modify anything it wigs out.

    Help!

    Tuesday, October 27, 2009 10:03 PM

Answers

  • You've unfortunately inherited a badly designed app ... my advice has been to avoid TableAdapters, but since you're stuck with them I guess you'll have to make do.

    There is no BaseTableAdapter class in .NET, so it must be a custom class. Are you missing some references?
    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    • Marked as answer by Yichun_Feng Tuesday, November 3, 2009 6:33 AM
    Sunday, November 1, 2009 10:16 PM
  • I fixed it by adding implements ISupportInitialize in that base class and it was happy.

    Think it was a designtime deal with the designer.

    Thanks for your help.

    • Marked as answer by LightStamp Tuesday, November 3, 2009 8:59 PM
    Tuesday, November 3, 2009 8:59 PM

All replies

  • It actually won't even build once Open up the designer and do anything with it I immediately get an error in the ide in the generated code for each table adapter used where the table adapter has the line:

     

    Partial Public Class qTableAdapterXX

     

    Inherits Global.BaseTableAdapter

    This BaseTableAdapter is a component that provides a new connection class
    Do all table adapters require a "BaseTableAdaptor of sorts?  Does the wiward create this component?

    I'm a contractor and this is all inherited code that i need to modify.

    It's a WinForm app and when I get it from VSS it'll run but as soon as I select a method from a table adapter in the design view of the XSD and right click and select view code it immediately gives 27 errors - one for each ot the table adapters saying "Type 'BaseTableAdapter' is not defined.   If I click on the error I see the generated code

    Partial Public Class qTableAdapterXX

     

    Inherits Global.BaseTableAdapter

    How do I correct this when it's a mix of generated code and modifications needed.  I don't know how much was generated by VS2005 and how much was manually coded......

    Wednesday, October 28, 2009 2:02 PM
  • I've got an existing form that is bound to an XSD as the datasource.  It contains 27 different queries and the accompaning data adapter.

    All I need to so is add a new column Attribute to the form and bind it to an existing query which i've already changed in the database to return this new field Attribute (tinyint, no NULLS)
    Like I said all the functions for the one (0f the 27) table adaptors - the stored procedure that that function uses as the command has been changed in the database.

    I want to, in a minimally evasive way, bind this new additional textbox on the form to pick up the Attribute field when populating the form.

    I've actually added the line

            Me.AttributeTextbox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.QAfItemsBindingSource, "Attribute", True))
           
     to the InitializeComponent which i will see what happens but I know i need to alter the XSD somewhere to to add this field to the structure.
     When I try to modify using the configure right click option on the table adaptor it blows up saying it can't recognize the BaseTableAdaptor which each of the 27 table adaptors tries to inherit from.....
     
     Can I manually change these things to make this work?

    • Merged by Yichun_Feng Friday, October 30, 2009 10:40 AM duplicate thread
    Wednesday, October 28, 2009 4:22 PM
  • I guess replying to my own question makes me fill I'm doing something.  How could a component that is within the same project not be defined? 

    I get an error for every reference of

    Inherits Global.BaseTableAdapter

    This is in the generated code.  How can I make this code "see" the BaseTableAdapter component?

    I'm completely miffed! 

    Someone please help me.

    Harry
    Thursday, October 29, 2009 2:49 PM
  • You've unfortunately inherited a badly designed app ... my advice has been to avoid TableAdapters, but since you're stuck with them I guess you'll have to make do.

    There is no BaseTableAdapter class in .NET, so it must be a custom class. Are you missing some references?
    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    • Marked as answer by Yichun_Feng Tuesday, November 3, 2009 6:33 AM
    Sunday, November 1, 2009 10:16 PM
  • Thanks Bonnie,

    I think it is SO BADLY designed that it is not maintainable.  I talked with a programmer that had worked on it earlier and he said he got around the error on the Inherits Global.BaseTableAdapter by dropping the Global. and just having Inherits BaseTableAdapter.  Sure enough in voodoo fasion it went away - the errors.

    So that's a possible workaround for that.  Now I have a larger problem.  I'm trying to add a single textbox and a combo box and a label to the panel on the form I'm working on.  Everytime I add to this form and try to run the app it errors out with

    InvalidCastException: Unable to cast object of type 'MxSellItemMaint.dsSellITemMainTableAdapters.qFeItemsTableAdapter' to type 'System.ComponentModel.ISupportInitialize

    at  CType(Me.QFeItemsTableAdapter, System.ComponentModel.ISupportInitialize).BeginInit()

    and I think this may be tied to the fact that the table adapters use a base class component that was written which does nothing more than return the current connection string to the table adapters.

    Thinking out loud but maybe that base component is not supporting ISupportInitialize ........

    It has this as the header:

    Public

     

    Class BaseTableAdapter

     

    Inherits System.ComponentModel.Component

     

    Public Sub New()

     

    MyBase.new()

     

    End Sub



    Tuesday, November 3, 2009 2:06 PM
  • Well, the TableAdapter class itself (that VS generates)  doesn't implement ISupportInitialize interface, so unless the BaseTableAdapter class does, then yeah, it's going to give you compiler errors. And looking at the code snippet from your post, it sure doesn't look like it's trying to implement ISupportInitialize.

    So of course, that makes me wonder where that line of code (below) came from?

    CType(Me.QFeItemsTableAdapter, System.ComponentModel.ISupportInitialize).BeginInit()


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Tuesday, November 3, 2009 8:48 PM
  • I fixed it by adding implements ISupportInitialize in that base class and it was happy.

    Think it was a designtime deal with the designer.

    Thanks for your help.

    • Marked as answer by LightStamp Tuesday, November 3, 2009 8:59 PM
    Tuesday, November 3, 2009 8:59 PM
  • Quite obvious then that the application you've "inherited" never even compiled before. Lovely. Best of luck with it all ... it sounds like it will be quite a handful! =0(
    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Thursday, November 5, 2009 5:39 PM
  • Oh it compiled fine it's just the designer barfed in design time if I tried to open it.

    But thanks for the help

    Harry
    Friday, November 6, 2009 6:17 PM
  • But that makes me wonder though ... did somebody tweak some designer-generated code when they shouldn't have? Or were some references broken at some point and consequently it previously compiled with an out-of-date reference? I mean, you have to admit that something funky was going on.  ;0)

    But, anyway ... you've got it fixed. Hopefully there won't be too many more such problems. =0)
    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Saturday, November 7, 2009 12:44 AM