I’ve seen this error a couple of different times. Mostly from other people calling me with the problem. So I still don’t know what ultimately causes the problem. But if you’re having this problem, here’s how you fix it.
First, a bit of background.
You’ll open a dataset you’ve been working with for months and see the following error message:
Unable to find connection [connectionName] (web.config)1 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.
What has happened is that the list of connection strings the tables in your dataset use has become corrupt. In the most recent case of this we ended up with two connection strings with the same name pointing to two different connections.
Here’s what you need to do to start trouble-shooting the problem.
- Close the dataset window with the error.
- Right click the dataset in the solution explorer
- Select “Open with…” from the context menu
- Select “Source Code (Text) Editor” from the list and press the “OK” button.
Your code will now be opened in text mode so you can view the XML. You want to be careful at this point because if you mess things up too badly, you won’t have anything useful. As things stand now there is hope of recovery. A backup would be a good thing to make sure you have right about now.
Near the top of the file, you’ll see a <connections> element with several <connection> elements within it. Most datasets should only have one <connection> element. If you are having trouble like I’ve described above, you’ll have at least two and one will be incorrect. Delete it or otherwise fix it, save the file and reopen normally. If you are lucky, everything will be working correctly again.
Other post in ASP.NET
- ASP.NET GridView Edit All Rows At Once - October 30th, 2007
- Validating A WebForms Checkbox . . . - January 4th, 2008
- ListView and the DataPager - January 7th, 2008
- The case of the disappearing session variables - January 14th, 2008
- Storing a DataRow into a Session (server) variable - January 15th, 2008
- The point of a multi layer architecture - January 31st, 2008
- FormView Edit and Add - May 12th, 2008
- Virtual Files using HttpContext.RewritePath() - July 17th, 2008
- ASP.NET AJAX using JSON - Here's how. - August 4th, 2008
- SystemException: The trust relationship between the primary domain and the trusted domain failed - November 18th, 2008
- GridViews - Multiple Rows Per Record - December 17th, 2008
- Response.Redirect() executes too soon on the Server. - January 27th, 2009
- Tab Control ActiveTabIndex Lost on Postback - February 25th, 2009
- ASP.NET Application_Error Detecting 404's - March 2nd, 2009
- Infinite 302 Loop - How would you even know? - March 11th, 2009
- Unable to find connection...for object web.config - March 18th, 2009
- Dynamically Change class Attribute From ASP.NET - September 29th, 2009
- HttpContext.Items vs Session - October 12th, 2009
- Access a control by ID From Within a Databound Control - November 2nd, 2009
- GridView and Updating A Row Manually - November 4th, 2009
- Embedding Google Search Appliance Results in ASP.NET - November 5th, 2009
- ASP.NET Cross Domain Form Submission - November 11th, 2009
- ASP.NET Interview Questions For New College Graduates - November 12th, 2009
- ASP.NET Dynamic Validator - November 16th, 2009
- The Google Appliance and Forms Authentication - August 4th, 2010
- Prevent Postback on Buttons - October 11th, 2010
- Azure CDN Blob Storage Case Sensitive Issue - April 17th, 2012
- ASP.NET JSON and ViewState - September 25th, 2012
- Panel DefaultButton does not work - December 25th, 2012
- Why CSS ID selectors are Evil in ASP.NET Web Forms - February 26th, 2013
- Sorting the ListView in ASP.NET - March 5th, 2013
- Multi-Step Processing in ASP.NET - May 8th, 2013
- ASP.NET Web Design Software - May 15th, 2013
- Test Sending Email without a Server in ASP.NET - June 5th, 2013
- Tracking Down Performance Issues in ASP.NET - July 24th, 2013
- Unrecognized Tag Prefix or Device Filter ‘asp’ - July 31st, 2013
- WebServices – Error Handling - December 11th, 2013
- Converting a DataList to a ListView - December 25th, 2013
- What’s the Truth about Running ASP.NET WEBAPI Asynchronously? - November 15th, 2016