Did something happen to the table adapters in ADO.NET going from 3.5 to 4.0?

Question Did something happen to the table adapters in ADO.NET going from 3.5 to 4.0?

  • mardi 28 février 2012 22:22
     
      A du code

    I'm working on upgrading a WCF service I wrote, back in 2009, which uses ADO.NET datasets.  Back then I was trying to work with datasets that contained lots of data tables coming across the wire, and putting them all into a table adapter manager, to perform a save.  I created several .XSD files, associated with all of the tables (of which there are a lot) in the  2 databases that I've got to save data to.  I opened up the solution (3 projects in it) in VS 2010 and started the work to make the changes.  Now, this was 3 years ago, and frankly at this point without spending hours trying to find all of my notes on what I was thinking back then, I don't remember everything I was doing, but there's a lot of code that looks something like this:

    ASIDataSetTableAdapters.ASIIncomeLast30TableAdapter last30 = new ASIDataSetTableAdapters.ASIIncomeLast30TableAdapter();
    Last30.Connection = cn;  //an ADO.NET SqlConnection object
    

    I've got a LOT of lines like that.  When this project was under .NET 3.5/VS 2008, this compiled and worked fine.  Now, with VS 2010/.NET 4.0, all of those *TableAdapter objects are declared as “does not exist”, when I try to compile this.  Like I said, I don't remember what I was doing, but when it gives me 176 lines of errors all about this, I'm frustrated.  What happened going from .NET 3.5 to 4.0 to the table adapters?  Why were they OK, back then but not now?  Have they been replaced?  Are they now hidden, whereas they used to be open before?

    Rod

    • Déplacé Papy Normand mercredi 29 février 2012 12:45 Not well placed in SQL Server Data Access (From:SQL Server Data Access)
    •  

Toutes les réponses

  • mercredi 29 février 2012 07:06
     
     
    Hi Rod,

    This issue is relational to the difference between ADO.NET 3.5 and 4.0 after upgrade. For better assistance, I would like to recommend you open a thread on ADO.NET DataSet forum. For your reference, please see: TableAdapter.

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.


    Stephanie Lv

    TechNet Community Support

  • mercredi 29 février 2012 12:42
     
     

    Hello Stephanielv,

    I am following your advice : i will move this thread to the ADO.Net forum.

    Thanks

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

  • mercredi 29 février 2012 12:47
     
     

    Hello Rod at work,

    Move done. I hope you will find a full and quick answer on this forum.

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

  • mercredi 29 février 2012 17:06
     
     
    Thank you, Papy, for moving my question to a more appropriate forum.  I'm sorry I didn't post it here to begin with.

    Rod

  • mercredi 29 février 2012 17:24
     
      A du code
    Hi Rod,

    This issue is relational to the difference between ADO.NET 3.5 and 4.0 after upgrade. For better assistance, I would like to recommend you open a thread on ADO.NET DataSet forum. For your reference, please see: TableAdapter.

    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.


    Stephanie Lv

    TechNet Community Support

    Hi Stephanie,

    So, are you saying that the DataSet object, as generated in the .XSD file, automatically calls the AcceptChanges() method, before it does any Update()?  And how would that explain why compiling my app now makes all lines involving a reference to the TableAdapters object as now being non-existent.  For example, in the line:

    ASIDataSetTableAdapters.ASIIncomeLast30TableAdapter last30Adapter = new ASIDataSetTableAdapters.ASIIncomeLast30TableAdapter();

    It is the ASIDataSetTableAdapters object which VS 2010 now considers non-existent.  It existed when I had it under VS 2008 and .NET 3.5.

    Rod

  • mercredi 29 février 2012 17:32
     
     
    Just a quick addendum: one of my colleagues suggested that I set the framework used in the project back to .NET 3.5, just to see what happens.  So I did, and now when I compile it doesn't complain at all about the ASIDataSetTableAdapters object.  Why is that?

    Rod

  • mercredi 29 février 2012 21:29
     
     
    I tried putting my solution, and all of it's projects, back to .NET 4.0, and from there continue to figure out what went wrong.  I've been digging through the auto-generate ADO.NET dataset code, and comparing that to what I've got in source control, and I believe I now know what the problem is.  The conversion, from .NET 3.5 to .NET 4.0 wiped out the TableAdapterManager class in all  of my .Designer.cs files.  ALL OF THEM!  I was relying upon the table adapter manager to perform the save of tables in the proper order (parent tables first, followed by child tables).  Why did it wipe the table adapter manager class definitions out?  I don't have time to investigate all of the class attributes associated with the class, methods, etc. in the old .NET 3.5 configuration that didn't make it into the .NET 4.0 version, so I'm just going to bag the whole thing, roll back to VS 2008/.NET 3.5 and try to recover as best I can.

    Rod

  • jeudi 1 mars 2012 10:14
     
     

    Rod,

    I see it is reported, maybe you could vote for some quicker solution

    :-)

    https://connect.microsoft.com/VisualStudio/feedback/details/583180/the-auto-generated-code-of-tableadaptermanager-class-in-vs2008-and-vs2010-are-different  

    By the way, the answering mechanism in Connect is for me not always the clearest, I always get the idea things get sometimes a sudden dead. 

    But did you install VS2010SP1?


    Success
    Cor



  • jeudi 1 mars 2012 16:52
     
     

    Hi Cor,

    I saw that article on Connect yesterday, but thank you very much for posting the link anyway (I may have missed it, after all).

    I do have VS 2010 SP1 installed.  It's been on my  machines for quite some time now.


    Rod

  • lundi 5 mars 2012 09:00
     
     

    Hi,

    as i understand it, the issue Cor describes is solved in sp1, only, your isssue is that you can't use 2008 managers in 2010.

    I'm not sure what happens in your code, but i suppose the dataset(s) 'Hierachical Update' property is set to false.

    Setting them to 'True' would generate the 2010 versions of the manager(s), which would solve your problem.


    Regards, Nico

  • lundi 5 mars 2012 21:35
     
     

    Hi Nico,

    I've checked and the 'Hierarchical Update' property for the datasets is set to true.  It was when I had it in VS 2008/.NET 3.5, and that carried over when I upgraded it to VS 2010/.NET 4.0.  Since the TableAdapterManager classes were all wiped out for all of my datasets after upgrading it, I decided to just roll back to VS 2008/.NET 3.5.


    Rod

  • mardi 6 mars 2012 07:58
     
     

    It was when I had it in VS 2008/.NET 3.5, and that carried over when I upgraded it to VS 2010/.NET 4.0. 

    Are you sure it carried over? Is it not possible that by setting it to 4.0 those properties were set to false?

    Afaik, TableAdapterManager classes are automatically generated when the dataset is saved while that  'Hierachical Update' property is set to True.

    I can imagine that the manager class in 4.0 is somewhat different from the one generated in 3.5, so it may be a deliberate strategy to set it to false when an older version is detected. Setting it to True again should generate the manager classes.


    Regards, Nico