Hello,
What are the steps to create an ODBC connection to Access database?
Could someone please list for me the steps. I would like to create an ODBC connection to reuse it in my applications.
Thank you very much in advance.
Thanks
Hisham
Printable View
Hello,
What are the steps to create an ODBC connection to Access database?
Could someone please list for me the steps. I would like to create an ODBC connection to reuse it in my applications.
Thank you very much in advance.
Thanks
Hisham
Dim Cnn As ADODB.Connection
Dim strConnect As String
Set Cnn = New ADODB.Connection
'Substitute your own User IDs, Password, Data Source, and System
'database in the connection string below
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Password=MyPassword;User ID=Administrator;" & _
"Data Source=C:\AccessDBs\DB1.mdb;" & _
"Persist Security Info=True;" & _
"Jet OLEDB:System database=C:\AccessDBs\system.mdw"
With Cnn
.CursorLocation = adUseClient
.Open strConnect
End With
Iouri Boutchkine
[email protected]
Iuri,
Thank you for your response. But, is there a way to configure the ODBC prior to everything and us the name of the ODBC to connect. I thought I have seen something like that. They go to start menu>settings>control panel>data sources(ODBC)
Have you done something like that?
Thanks
Hisham
In control panel-> ODBC you have to create Data Source Name (DSN) and then you can open database
Set MyDB = Workspaces(0).OpenDatabase("DSN=MyDsN")
I would not recommend this because you have to install DSN on every PC where you install your program
Iouri Boutchkine
[email protected]
I found the piece of code for you with DSN
sConn = "ODBC;DSN=MyDSN;uid=;pwd=;"'doesn't work
'Open Connection Object
Set cn = New ADODB.Connection
cn.ConnectionString = sConn
cn.Open
Iouri Boutchkine
[email protected]