Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to display data from MSaccess 2007 into gridview control.
My code is giving Unhandled exception "Keyword not supported: 'provider'".
My source code is given below.
C#
string connection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Documents and Settings\\Administrator\\My Documents\\my.accdb";
 string query= "Select * from fee where status=Pending ";
 SqlDataSource sds = new SqlDataSource(connection,query);
GridView1.DataSource = sds;
           GridView1.DataSourceID = String.Empty;
           GridView1.DataBind();

Please help me out for the same.

Thank&Regards
Abhishek
Posted
Updated 26-Mar-11 20:14pm
v2

1 solution

Well, it's quite clear that the connection string formed has issues.

I would suggest you to have a loot here at Connection String[^]!

The link above provides all info about connection string. Further info regarding the data communication can be read here: Accessing data with ADO.NET[^]

Out here, you are working with SQL, you don't need to give the provider. Just remove the Provider and things should be fine.
 
Share this answer
 
v2
Comments
abhiamity86 27-Mar-11 2:50am    
Thanks For helping me.

But somehow my sql is not working so i did some modification in source code.
It is again giving Exception 'Data Source=C:\Documents and Settings\Administrator\My Documents\my.accdb' is not a valid virtual path.
My New source code is-

string connection = "Data Source=C:\\Documents and Settings\\Administrator\\My Documents\\my.accdb";
string query= "Select * from fee where status=Pending ";
AccessDataSource ads = new AccessDataSource(connection,query);
GridView1.DataSource = sds;
GridView1.DataSourceID = String.Empty;
GridView1.DataBind();
Pls help me.

Thanks&Regards
Abhishek
Sandeep Mewara 27-Mar-11 3:01am    
Your connection string is wrong. Try the websote and get it correct for yourself.

Further, the error again says it's expecting a virtual path based on the root.
abhiamity86 27-Mar-11 3:24am    
Thanks For Reply,

I am Beginner to Programming.
So I am not getting ,how can i resolve this issue.
Would you pls help me.

Abhishek
Sandeep Mewara 27-Mar-11 3:25am    
Go through the connectionstring link I gave.
abhiamity86 27-Mar-11 5:41am    
I have go through enough but unable to get solution.
pls help me.

Abhishek

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900