Home » ASP.NET » Unable to find connection…for object web.config

Unable to find connection…for object web.config

J01C0089 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

Related Post

  • DataSets, ObjectDataSource and 3-Tier ASP.NETDataSets, ObjectDataSource and 3-Tier ASP.NET As I've mentioned in other post, while I think LINQ has it's uses, I still favor the use of the ObjectDataSource control in conjunction with DataSets and a 3-tiered architecture.  Since […]
  • Overriding Events in VB.NETOverriding Events in VB.NET Back in the day, you use to be able to override an event in VB by using the drop down list in the code window.  Today, I had a friend who is moving from Visual Studio 2003 to Visual Studio […]
  • GridView and Updating A Row ManuallyGridView and Updating A Row Manually A couple of days ago I mentioned a project that I’ve been working on that is a bit out of the ordinary as far as GridViews go.  One of the issues I’ve had is that the edit template […]
  • HttpContext.Items[] vs Session[]HttpContext.Items[] vs Session[] Since .NET first became available, passing data around during a request has become a lot easier.  The ability to set a property has made that so.  Still, there are times when […]
  • Converting a DataList to a ListViewConverting a DataList to a ListView Yesterday, I spent the bulk of the day converting a DataList to a ListView.  I thought I'd spend a little time relating the process for those of you who might be interested in doing […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS. Does your team need additional help in any of the above? Contact Dave today.

  • Ibrahim

    Thank you for this solution, I solved my issue by following your step:

    But then I received other error which caused by missing provider name in the connection string inside the web config.
    ( providerName=”System.Data.SqlClient” )

    Thank you so much..

    Regards,

    Ibrahim Al Hammadi