Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have a project in C# windows base, I m not able to connect to the ms access can any one hale me please? below code is given

C#
private OleDbConnection con = new OleDbConnection();

 con.ConnectionString = Microsoft.VisualBasic.VBCodeProvider
Posted
Updated 28-Apr-11 22:59pm
v2

Take a look at http://www.connectionstrings.com/access-2007[^]

What kind of exception do you get?
 
Share this answer
 
If you look at the Server Explorer pane in visual studio, then click on your database, the connection string will be listed in the Properties pane.
Copy this, and paste it as the connection string in place of "Microsoft.VisualBasic.VBCodeProvider" in your code above.
 
Share this answer
 
Hi,

Have a look at Different ways of ConnectionStrings:

For Access[^]
For Access 2007[^]

P.S: Please check connecting properly.
 
Share this answer
 
There is another question related to this:
Connection string in C#.net[^]

I hope this one helps.
 
Share this answer
 
OleDbConnection dbconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename_with_Location + ";Jet OLEDB:Database Password=****;");
OleDbDataAdapter dAd = new OleDbDataAdapter("SELECT * FROM table", dbconn);
                DataTable dt = new DataTable();
                dAd.Fill(dt);


Hope this can help you.
 
Share this answer
 

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