connecting to access db

K

Kavvy

I'm working on a Win app and in the Data tab there are only classes for
OleDB and Sql.

I create an OleDB (Using the Microsoft OLE DB Provider for ODBC) connection
to my Access DB, but it throws the following error when I try to actually
drag a table onto the form.

"You cannot use a OLE DB provider for ODBC drivers"

Any ideas on what might be wrong?

Thanks
Rich.
 
D

Derek Harmon

Kavvy said:
I'm working on a Win app and in the Data tab there are only classes for
OleDB and Sql.

From this I'm inferring you're using Visual Studio .NET 2002 and
therefore do not have System.Data.Odbc (added in VS 2003)
available.
I create an OleDB (Using the Microsoft OLE DB Provider for ODBC)
connection to my Access DB, but it throws the following error when I
try to actually drag a table onto the form.

"You cannot use a OLE DB provider for ODBC drivers"

Any ideas on what might be wrong?

This is correct, the OLE DB Provider does not support OLE DB-ODBC
as the underlying driver stack.

Is there any particular reason you must use ODBC? You state that
it's an Access database you are connecting to, if that's a fixed part
of your application's design, why not use the OLE DB Provider for
the native Microsoft Jet driver?

Create an OleDbConnection (et al) as you normally would, and use
this as the connection string (substituting the drive path to your .mdb
file, of course):

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydir\myData.mdb;"

That's the vanilla connection string, if you have a user name, password,
file sharing, or other requirements the ConnectionString can grow much
more complex.


Derek Harmon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top