Showing posts with label sqldatasource. Show all posts
Showing posts with label sqldatasource. Show all posts

Friday, February 24, 2012

Connection string problem

I'm converting a simple Access application to ASP.NET with MSDE to run on our Intranet. The app has just one page with 2 SqlDataSource controls. Initially I configured the data source to connect directly to the .mdb file. Once I got the code running, I used the "Upsize Wizard" in Access to convert the data to a SQL database using the MSDE instance running on my web server. I then re-configured the SqlDataSources to connect to the MSDE database.

I am able to step all the way through the configuration wizard, and when I test the query, the correct data is returned. However, when I run the app (from within Visual Web Developer Express) I get the following exception when I bind a drop-down list to one of the SqlDataSources:

An OLE DB Provider was not specified in the ConnectionString.  An example would be, 'Provider=SQLOLEDB;'.
The connection string generated by the Wizard in my web.config is this:

<

addname="ConnectionString"connectionString="Data Source=BCFWEB01;Initial Catalog=InOut;User ID=XXX;Password=XXXXXXXXX"providerName="System.Data.SqlClient" />

Any idea why its complaining that I don't have an OLE DB provider, and why the query works fine from the Configuration Wizard but not when I run the page?

Thanks,

what is your code to bind your datasource? This errors mostly occurs when you are using OleDb connections in your code, and you have an Sql connection in your web.config file.|||Problem went away when I deleted & recreated the data source. I no longer have the code that didn't work :) but I suspect that's what the issue was. Thanks for the help!

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