troubleshooting Question

SqlDataSource and Dataset

Avatar of hanleywood
hanleywood asked on
DatabasesWeb Applications
1 Comment1 Solution2866 ViewsLast Modified:
Hello I am trying to use visual studio 2008 to make a site that connects to a access 2003 database.  I am using the SqlDataSource control for the connection and it gives me this connection string "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\Hydrocycle.mdb;Persist Security Info=True"

And when i test the select * query using visual studio query tester it returns all of the values like it should.  The problem is this.  When i try to fill a data set with a data adapter that is using the SqldataSource's connection it throws this error; "System.ArgumentException: Keyword not supported: 'provider'."

So i took out the provider portion of the connection string and it threw a new error; "An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005"  It seems it does not know to connect to an access database now and instead tries to go to a sql server database which is way off.
I have looked up the provider error and one guy said

"This is ADO.Net code. There is no reason to specify the provider. The SQLConnection object can only connect to SQL Server.

The OLEDBConnection object is the one used to connect to any datasource thus it would require a provider."

That makes no sense to me because if you take out the provider it no longer knows what database to look for.

Ive also verified the connection string by going to http://www.connectionstrings.com/ and every one of their access connection strings had a provider in it.  So why would the data adapter throw an error that said keyword provider not supported when trying to connect.  Why will it not connect and fill my data set.  I am stumped.  Thanks for any help in advance.

System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(SqlDataSource1.SelectCommand, SqlDataSource1.ConnectionString);
        DataSet ds = new DataSet();
 
        sda.Fill(ds);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros