5 replies
by andrew
I prefer to use ADO. This is based on OLEDB and is quite fast.
Here's an example:
Private Sub ListAuthors()
Dim oCon As ADODB.Connection
Dim oRs As ADODB.Recordset
Set oCon = New ADODB.Connection
oCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\pubs.mdb;"
Set oRs = New Recordset
oRs.Open "SELECT * FROM Authors", oCon
Do
list1.AddItem oRs.Fields("au_lname").Value
oRs.MoveNext
Loop Until oRs.EOF
oRs.Close
Set oRs = Nothing
Set oCon = Nothing
End Sub
by iradalys
by miss kitty
This is the code that I use to open the Access database.
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objRS As New ADODB.Recordset
Dim objParam As ADODB.Parameter
Dim count As Integer
'set up the database pointer
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=E:\ACCESS\CONTRACT HAULERS\HAULER.mdb;User ID=ADMIN"
objRS.CursorType = adOpenDynamic
objRS.LockType = adLockOptimistic
'setting the Active Connection for the command object
objCmd.ActiveConnection = objConn
From here, you can run an Access Query or populate a datagrid. Whatever.
Cathy
covcat@riverstonegrp.com
by iradalys
by iradalys
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending