Click to See Complete Forum and Search --> : Opening a connection to an Access database using ADO??????????
kanejone
Nov 22nd, 2000, 09:41 AM
I have an Access database name called hello.mdb stored in C:\Databases. Can someone please show me how to connect to this database using ADO.
Thanks in advance
JK
Corby
Nov 22nd, 2000, 09:48 AM
Dim DSN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim strPath$
'Access Version
strPath = "d:\temp\test.mdb"
With DSN
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strPath, Uid, PW
End With
SQL = "Select * From Table_Name"
Rs.Open SQL, DSN, adOpenDynamic, adLockOptimistic
You can do anything you want with this. I usually
make DSN Global to the whole project, you can then
use it anywhere.
Corby
Nov 22nd, 2000, 09:49 AM
Dim DSN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim strPath$
'Access Version
strPath = "d:\temp\test.mdb"
With DSN
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strPath, Uid, PW
End With
SQL = "Select * From Table_Name"
Rs.Open SQL, DSN, adOpenDynamic, adLockOptimistic
You can do anything you want with this. I usually
make DSN Global to the whole project, you can then
use it anywhere.
Corby Nichols
kanejone
Nov 22nd, 2000, 10:20 AM
Thanks for the help
JK
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.