|
Question : Access VBA ODBC Connection
|
|
Hi
I have an Access database and want to create an ODBC connection to it. What is the easiest way to do this? I have never done one before
|
|
Answer : Access VBA ODBC Connection
|
|
see this link for reeference http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForAccess
* ODBC Driver for Access
For Standard Security:
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=c:\somepath\mydb.mdb;"
If you are using a Workgroup (System database):
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=c:\somepath\mydb.mdb;" & _ "SystemDB=c:\somepath\mydb.mdw;", _ "myUsername", "myPassword"
If want to open up the MDB exclusively
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=c:\somepath\mydb.mdb;" & _ "Exclusive=1;"
If MDB is located on a Network Share
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=\\myServer\myShare\myPath\myDb.mdb;"
If MDB is located on a remote machine
- Call an XML Web Service that contains data access web methods for MDB - Or upgrade to SQL Server and use an IP connection string
If you don't know the path to the MDB (using ASP)
<% ' ASP server-side code oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=" & Server.MapPath(".") & "\db\myDb.mdb;" %>
Make sure the Web identity has read/write permissions to the directory the MDB is located in. e.g. "db" would need the read/write permissions.
If you don't know the path to the MDB (using VB)
oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=" & App.Path & "\myDb.mdb;"
This assumes the MDB is in the same directory where the application is running.
|
|
|