Failed to load dataset because of the following error: Unable to find connection ...
- 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
- 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
- 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.
- 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> I have experienced this problem more than once. Now, thanks to your post, I know how to fix it!
Thank you!
Mark
Exactly the thing! Thanks for posting
Pat Tormey
New Hanpshire USA- 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.
- Thank you, thank you, thank you. Been tearing my hair out trying to fix this!
- Thanks for the fix. I've been working around this for a while.
- 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" /> - Thanks, that solved my poblem with a windows exe. I never would have guessed that as the problem.
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.
Quick Thanks!
Saved me a lot of time trying to debug this one!
- Thanks a lot man. Saved me some time for sure!
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.
Oh wow, thanks you guys.
What a relief!!
Danny
- 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 Thanks for posting this, it was a big help.
Stuart
- Thank you. I never would have figured this out.
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.
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" .... etcand in the tableadapter sections:
<
DbSource ConnectionRef="BHPWasteConnectionString (Web.config)" ... etcto this:
<Connection AppSettingsObjectName="MySettings" AppSettingsPropertyName="connectionname" .... etc
and in the tableadapter sections:
<
DbSource ConnectionRef="BHPWasteConnectionString (MySettings)" ... etcIt worked for me. Hope it might help someone else.
Thanks Skycro, Missing Provider was my problem. Cheers
Thank you!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!
I have the same problem.
Thanks for the answer
- 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 2008Uninistalled VS 2008Uninstalled XP SP 3Uninstalled IE 8 Beta 2Deleted the directory where the source code wasReinstalled XP SP 3Reinstalled VS 2008Reinstalled ankhSVN for VS 2008Re-checked out the code from SVNAfter 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.


