Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Access with ADO

Status
Not open for further replies.

ping99

Technical User
Mar 16, 2006
45
CA
Hi all,

I am newbie to ADO to open an NorthWind.mdb such as employee table .

Can someone help me with the syntax in VB to do this ?

Sqlstr = ' select * from employee '

TIA
 

Start off by reading faq222-2244, which gives guidance on forum usage and basic research, as there are examples of ADO usage in VBHelp.

To get you started you need to set up a connection to the database and set up a recordset object, then open the recordset using your query string
Code:
 Dim cn As ADODB.Connection
 Dim rs As ADODB.Recordset
 Dim strSQL As String
    Set cn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\biblio.mdb"
strSQL = "select * from employee"
rs.Open strSQL, cn
rs.MoveFirst

Do While Not rs.EOF
'do your thing with records here
rs.MoveNext
Loop
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing

You will need to change the db path of course

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top