Link to home
Start Free TrialLog in
Avatar of hanleywood
hanleywood

asked on

SqlDataSource and Dataset

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);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hanleywood
hanleywood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial