Click to See Complete Forum and Search --> : How to create ODBC?
hoa01206
October 23rd, 2001, 09:50 AM
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
Iouri
October 23rd, 2001, 10:23 AM
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
iouri@hotsheet.com
hoa01206
October 23rd, 2001, 10:50 AM
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
Iouri
October 23rd, 2001, 11:15 AM
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
iouri@hotsheet.com
Iouri
October 23rd, 2001, 11:21 AM
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
iouri@hotsheet.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.