General discussion

Locked

VB6

By iradalys ·
What code can I use to access/open a Access database?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

VB6

by andrew In reply to VB6

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

Collapse -

VB6

by iradalys In reply to VB6

The question was auto-closed by TechRepublic

Collapse -

VB6

by Miss Kitty In reply to VB6

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

Collapse -

VB6

by iradalys In reply to VB6

The question was auto-closed by TechRepublic

Collapse -

VB6

by iradalys In reply to VB6

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums