Friday, February 10, 2012

Connection problem

I am trying to connect a GridView to an SqlDataSource control and am getting the following error message: Following error occurred while getting connection string information from configuration. "Cannot get web application service" I added a connection successfully. I previously had Beta 2 installed and it worked. Now I am getting this error. Please help.I'm having the same issue, but did NOT have Beta 2 installed (in case someone considers that a factor)
Thanks,
Chris|||

Actually, chalk this one up to the Bizzarre Department:

I had manually created 2 data connections to 2 SSE databases on the same box as the VS2005 Pro. No problem. I usually deal with my data connections and access by hand and not by control, so this was my natural first step in order to be able to work with the database though the VS IDE.

When I dropped the SQLDataSource control onto the page and attempted to deal with the connection attributes, I received the above message.

So I removed both dB connections from the server browser and opened a new ASP.NET web project. I dropped the SQLDataSource control to the blank, pristine DEFAULT.ASPX page. When I clicked on the link to configure the properties, it worked perfectly fine.

I THEN went back to the original project, now with NO data connections in the server explorer. I dropped the SQLDataSource control onto the page where I had been having the issues before, and it worked fine. I deleted the control and re-added the data connection via the server explorer, and re-added the control. Again, no error. Even when I re-added the OTHER connection via the server explorer, I was able to drop the control and access it without issue. In fact, the config wizard picked up both data connections as expected.

It seems that because I had defined the items in the server browser BEFORE I tried the SQLDataSource control, it had issues. When they were removed, the control worked fine, even after adding the connections back in via the server browser.

The ONLY other thing that was different was that the web.config file for the original project that was throwing errors had a value for the <ConnectionString> which pointed to one of the two original data connections defined via the server explorer. I had removed the connection string info...but didn't actually re-format the XML properly for an empty element (my bad). My second project had a correctly formatted web.config file, and the success on the original project seemed to come after I went and properly formatted the web.config file.

Hope some of this rambling helps!

Chris

No comments:

Post a Comment