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.

[960 byte] By [JimSn] at [2007-12-17]
# 1
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.
JimSn at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
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>

JimSn at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3

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

Thank you!

Mark

Good-man at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 4

Exactly the thing! Thanks for posting

Pat Tormey
New Hanpshire USA

pattormey at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 5
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.
jwk1 at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 6
Thank you, thank you, thank you. Been tearing my hair out trying to fix this!
CosmicSheep at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 7
Thanks for the fix. I've been working around this for a while.
mduffin at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 8
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" />

skycro at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 9
Thanks, that solved my poblem with a windows exe. I never would have guessed that as the problem.
JimTheGreat at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 10

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.

JRMcFetridge at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 11

Quick Thanks!

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

BugaLugz at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 12
Thanks a lot man. Saved me some time for sure!
MixfromLatvia at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 13

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.

Moojjoo at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 14

Oh wow, thanks you guys.

What a relief!!

Danny

DannyAdler at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified