Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi again, matt here

got a problem connecting to a ms access database, the string i have been given cannot be found although it is on my flash drive

this is the code:
C#
OdbcConnection dbcon = new OdbcConnection(@"Data Source=E:\\data cent\\Northwind.accdb");

now i have a button to connect

C#
private void connectButton_Click(object sender, EventArgs e)
        {
            dbcon.Open();
            connectButton.Text = "Connected";
            connectButton.BackColor = Color.Green;
        }


i get this error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


I have added the data source manually with the data manager from the datagridview box.

Any idea where im going wrong please?
Posted
Updated 4-Feb-12 1:42am
v2

Hi There,

Hope This site http://www.connectionstrings.com/access[^] will help You.
 
Share this answer
 
Comments
BBCokeley 4-Feb-12 8:53am    
thank you, i have the connection string set up:
but it throws this exception all the time

@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Northwind.accdb"

System.Data.Odbc.OdbcException was unhandled
Message=ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

the site above doesnt seem to have a tutorial on driver manager, is there a site i can look up, this is getting frustrating.

just trying to display the data in a datagridview, but its having non of it.
BBCokeley 4-Feb-12 15:03pm    
sorry guys, missed out + between "" so it was throwing it, bloody code...lol

thanks every one got connected :)

thank you so much
Here[^] is the info on the connectionstrings website. I suspect you need to do more than just tell it the file location, this shows how to do that.
 
Share this answer
 
Comments
BBCokeley 4-Feb-12 7:46am    
thanks checking it out now
If you're using ODBC you should first define a DSN via Control Panel and give it a name. This name is then used as a data source.
 
Share this answer
 
Comments
BBCokeley 4-Feb-12 7:46am    
thank you looking into it

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