Data Platform Developer Center > Data Platform Development Forums > ADO.NET DataSet > Failed to load dataset because of the following error: Unable to find connection ...
Ask a questionAsk a question
 

StickyFailed to load dataset because of the following error: Unable to find connection ...

  • Sunday, October 09, 2005 7:25 PMJim Sn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Everything was fine last night, but this morning when I opened my VS 2005 web project, I got this message:

    Failed to load dataset because of the following error:  Unable to find connection X for object 'web.config'. The connection string could not be found in application settings, or the data provider associated with the connection string could not be loaded.

    Also, in my DatSet.xsd file, there are not 102 warnings that were not present before, and when I try to switch to Design view, I get "Cannot open a designer for the file because the class within it does not inherit from a class that can be visually designed."

    I cannot see anything obvioulsy wrong with the XSD file, but here are some of the warnings I get:

    "The 'AllowDbNull' attribute is not declared."
    (Also, lots of other attriubes are "not declared")
    "The element cannot contain white space. content model is empty."

    Can someone help be get my project repaired?

    Thanks.

Answers

  • Monday, October 24, 2005 2:35 PMJim Sn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    It turns out that the problem was duplicate connection strings in the .xsd file for the database, in the App_Code folder.  I don't know what put them in there or why the error messages gave so little useful information, but when I remove the duplicates, everything is fine.

    Below is a snippet from the .xsd file to illustrate. The <Connection> entries are identical in every way. To fix the problem, I removed all but one of them.

    <Connections>
       <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="MyConnectionString" ... </Connection>
       <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="MyConnectionString" ... </Connection>
    </Connections>

All Replies

  • Sunday, October 16, 2005 12:12 AMJim Sn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    For a while, I thought it was somehow caused by the use of stored procedures. I deleted the .xsd file for the database and began recreating it with the GUI. Everything when fine for a while, and I was able to exit VS and come back in.  Eventually, however, the exact problem occurred when I re-opened the project, so after a lot of work, I'm right back where I started.
  • Monday, October 24, 2005 2:35 PMJim Sn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    It turns out that the problem was duplicate connection strings in the .xsd file for the database, in the App_Code folder.  I don't know what put them in there or why the error messages gave so little useful information, but when I remove the duplicates, everything is fine.

    Below is a snippet from the .xsd file to illustrate. The <Connection> entries are identical in every way. To fix the problem, I removed all but one of them.

    <Connections>
       <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="MyConnectionString" ... </Connection>
       <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="MyConnectionString" ... </Connection>
    </Connections>
  • Friday, December 23, 2005 1:53 AMGood-man Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have experienced this problem more than once.  Now, thanks to your post, I know how to fix it!

    Thank you!

    Mark

  • Thursday, April 27, 2006 3:25 PMPat TormeyMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Exactly the thing! Thanks for posting

    Pat Tormey
    New Hanpshire USA

  • Thursday, April 27, 2006 3:57 PMjwk1 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    In addition to the above reason, if you break your web.config in some way, you get the same error.  Evidently, the dataset must read the web.config for the connection string information, but if the xml is malformed it fails with this error.
  • Thursday, May 25, 2006 8:21 AMCosmicSheep Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you, thank you, thank you. Been tearing my hair out trying to fix this!
  • Monday, June 19, 2006 6:05 PMmduffin Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for the fix. I've been working around this for a while.
  • Wednesday, November 15, 2006 12:26 AMskycro Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I recently enjoyed this error while I was trying to rename my datasets as well as my connectionstrings. I had moved the application to a remote development machine and had to change my connectionstring. While editing the connectionstring I managed to delete the providerName attribute.  It was a 45 minute oops.

    Wrong:
        <add name="COE_ApplicationsConnectionString" connectionString="Data Source=LOCALHOST;Initial Catalog=myDB;Integrated Security=True" />


    Correct:
        <add name="COE_ApplicationsConnectionString" connectionString="Data Source=LOCALHOST;Initial Catalog=myDB;Integrated Security=True" providerName="System.Data.SqlClient" />
  • Wednesday, November 29, 2006 6:37 PMJim TheGreat Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks, that solved my poblem with a windows exe. I never would have guessed that as the problem.
  • Tuesday, January 30, 2007 11:01 PMJRMcFetridge Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    we also just enjoyed this little gem ! One of our team ran into the situation after he had added 5 Tableadapters using the designer. I might add that this process was done incrementally and finally as the requirements of the project expanded he needed a sixth and was hit by this error. At this point the Designer was useless and no changes could  be made as the  error appeared on all operations. We were in a critical development stage so we loaded the project on my machine and things magically worked (at least for a while) and he continued development on my machine while I got on the phone with Microsoft support. This was only done as a last resort after searching all the forums and after 4 hours the MS team still could not find the problem. In the meantime my teammate was again hit by the problem on my machine and development halted. However he is a resourceful type and started looking around experimenting by removing a directory that was used by our source control (normally not a good thing to do) and suddenly things started working and he could use the Designer. I shared this with the MS support person and we tried the same thing on his machine but to no avail. We then copied over the entire project from the machine with the operational Designer and magically problem solved .

    I have no problem spending hours on a problem as long as we learn the cause however we really learned nothing except TableAdapters are very fragile.As a result I encourage anyone to backup their projects before using the Designer . Strongly-typed datasets are a pretty good tool at least until we have our hands on Linq but  our faith in designer tools has been shaken. As an architect I would love to move away from having to code at the SQL level but problems  like this are making the move slow.

  • Thursday, February 15, 2007 2:57 PMKevin Rowland Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Quick Thanks!

    Saved me a lot of time trying to debug this one!

  • Friday, March 30, 2007 6:31 PMambidexterous Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks a lot man. Saved me some time for sure!
  • Friday, June 15, 2007 4:37 PMMoojjoo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     recently enjoyed this error while I was trying to rename my datasets as well as my connectionstrings. I had moved the application to a remote development machine and had to change my connectionstring. While editing the connectionstring I managed to delete the providerName attribute.  It was a 45 minute oops.

    Wrong:
        <add name="COE_ApplicationsConnectionString" connectionString="Data Source=LOCALHOST;Initial Catalog=myDB;Integrated Security=True" />


    Correct:
        <add name="COE_ApplicationsConnectionString" connectionString="Data Source=LOCALHOST;Initial Catalog=myDB;Integrated Security=True" providerName="System.Data.SqlClient" />

    this is the answer that saved me thanks a million.

  • Sunday, June 17, 2007 7:53 AMDanny Adler Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Oh wow, thanks you guys.

    What a relief!!

     

    Danny

     

  • Sunday, August 05, 2007 11:05 AMOsama Askari Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Thank you for your post. I had the very same problem that caused me so much trouble. I opened the .xsd file and found 3 instances of the same connection string in it! I don't know where they came from but your post solved my problem.

    thank you so much
  • Tuesday, December 11, 2007 3:58 PMSturat Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks for posting this, it was a big help.

     

    Stuart

     

  • Wednesday, January 23, 2008 4:23 PMfhergen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you.  I never would have figured this out.

     

  • Monday, March 03, 2008 10:24 PMm.k.a Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Thanks for this post - solved my problem after 8 hrs and nearly going bald... The providerName was missing. I don't however recall ever deleting it.

     

  • Tuesday, April 15, 2008 4:03 AMmarshallartsoz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi All,

     

    The duplicate connections may not be the whole story.  I found and fixed one instance of such a duplicate in my ASP.NET project which has 20 or so datasets, but still got the error on all but 1 or 2 of them.  When I examined them closely and compared them with the ones that wouldn't work, the key difference seemed to be that the good ones referred to "MySettings" rather than "Web.config" in the connection definitions and references.  When I changed all these from "Web.config" to "MySettings" - presto, I can now use the designer and go in to configure methods on the tableadapters.  This problem has cost me many hours and lots of grey hairs!  I am hopeful that with this and the duplicate-connection knowledge I now have a handle on how to fix this.  But I really, REALLY wish Microsoft would just fix what causes it in the first place - it's a mongrel!

     

    So, what I changed was this:

     

    <Connection AppSettingsObjectName="Web.config" AppSettingsPropertyName="connectionname" .... etc

     and in the tableadapter sections:

    <DbSource ConnectionRef="BHPWasteConnectionString (Web.config)" ... etc

     

    to this:

     

    <Connection AppSettingsObjectName="MySettings" AppSettingsPropertyName="connectionname" .... etc

     and in the tableadapter sections:

    <DbSource ConnectionRef="BHPWasteConnectionString (MySettings)" ... etc

     

    It worked for me.  Hope it might help someone else.

  • Sunday, July 20, 2008 8:08 PMmartin fowmes Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Thanks Skycro, Missing Provider was my problem. Cheers

  • Tuesday, September 02, 2008 9:47 AMmatt220 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Thank you!
  • Tuesday, September 02, 2008 9:50 AMTwirlyBo Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Followed the thread carefully - looks like there is something horribly wrong in the dataset designer (GUI).

    Hopefully it can all be sorted soon - my tuppence worth follows.

     

    After trying all the above I realised that the name of the Connection String was set to 'whatever (settings)' which didn't seem right (it should be from my web config!)

     

    I added a new tableadapter and forced it to use the connection string from the config.

    Looked at the XSD file (notepad - its great!) and replaced all references to '(settings)'  to (Web.config)

     

    Lo and behold..it worked.

     

    If you get this far this may help you - it certainly did for me

     

    ( This project was converted from 2005 to 2008 - and i still had a few problems - had to go through each adapter and 'reconfigure' each - re: as load hit next a lot - then save!)

     

    Hoep to god to never have to do it again!

     

  • Wednesday, September 03, 2008 2:46 AMlanadaexiste Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have the same problem.

     

    Thanks for the answer

     

  • Tuesday, January 13, 2009 2:50 PMJhilden Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have VS 2008 and this problem started happening after I renamed datasets and moved them to a different directory.  The really goofy thing is that everything worked great for the same solution on my co-workers machine.

    unfortunetly none of the above solutions worked so I resorted to doing the following:

    Uninstalled ankhSVN for VS 2008
    Uninistalled VS 2008
    Uninstalled XP SP 3
    Uninstalled IE 8 Beta 2
    Deleted the directory where the source code was

    Reinstalled XP SP 3
    Reinstalled VS 2008
    Reinstalled ankhSVN for VS 2008
    Re-checked out the code from SVN

    After all that everything worked.  I'm sure that not all those steps were required to get it working for me again but I thought I would put them all down for completeness.