Click here to Skip to main content
15,917,481 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i using this code to connect DBF file but give me a connection error
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
How to fix this error?

C#
OdbcConnection conn = new OdbcConnection(@"Driver=Microsoft.Jet.OLEDB.5.0;Provider=vfpoledb;Data Source=E:\P2007\database\ACCOUNTS;Collating Sequence=machine;");
conn.Open();
string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]";
System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(strQuery, conn);
System.Data.DataSet ds = new System.Data.DataSet();
adapter.Fill(ds);
return ds.Tables[0];
Posted
Updated 28-Dec-14 17:36pm
v2
Comments
Maciej Los 29-Dec-14 2:21am    
Microsoft.Jet.OLEDB.5.0?

1 solution

The problem is most likely in the connection string.
Try this site, Connection Strings[^].
There you can find various variants of connection strings for different databases.

Here is a reference to Microsoft Support: HOW TO: Use Jet OLE DB Provider 4.0 to Connect to ISAM Databases[^]

Also check if you use 32 bit or 64 bit.
 
Share this answer
 
v3
Comments
Maciej Los 29-Dec-14 2:22am    
My guess, you're right ;)
+5!
George Jonsson 29-Dec-14 3:11am    
Well, that is the obvious thing to check. :)
Thanks, Maciej
manoj s sherje 29-Dec-14 23:35pm    
thank you sir for giving solution reference "Microsoft.Jet.OLEDB.5.0?" is a oledb driver
George Jonsson 31-Dec-14 2:54am    
Not sure microsoft.jet.oledb.5.0 even exist. You should try with microsoft.jet.oledb.4.0.
See my updated 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