Connection using ADO
Hi Alvin:
I use the following to connect to Access from
Excel. Substtide your path ect and you should get
hooked up. If you need the rest of the code to
retrive the recordset post back.
'To use ADO objects in an application add a reference
'to the ADO component. From the VBA window select
'Tools/References< check the box
' "Microsoft ActiveX Data Objects 2.x Library"
'You should fully quality the path to your file
Dim db_Name As String
db_Name = ("C:\Program Files\Microsoft Visual Studio\VB98\NWind.mdb")
Dim DB_CONNECT_STRING As String
DB_CONNECT_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"data Source=" & db_Name & ";" & ", , , adConnectAsync;"
'Create the connection
Dim cnn As New ADODB.Connection
Set cnn = New Connection
cnn.Open DB_CONNECT_STRING
If cnn.State = adStateOpen Then
MsgBox "Welcome to! " & db_Name, vbInformation, "Good Luck TK"
End If
Good Luck
TK
-----Original Message-----
I have some problems using ADO to retrieve data from an
Interbase (.gdb
file) in Visual Basic 6.0. I am trying to connect excel
speedsheet to
interbase but could not.
Here are some parts of the coding involving the database
connection:
' Database information
DBName = ThisWorkbook.Path & "\t6gl.gdb"
' Open the connection
Set Connect = New ADODB.Connection
Cnct = "Provider=MSDASQL.1;"
Cnct = Cnct & "Data Source=" & DBName & ";"
Connect.Open ConnectionString:=Cnct
The error message appeared like this:
Run-time error '-2147467259 (80004005)':
[Microsoft][ODBC Driver Manager] Data Source Name not
found and no default
driver specified.
Can someone look at this problem and any solution
provided will be highly
appreciated.
Alvin.
|