Link to home
Start Free TrialLog in
Avatar of jmrasmus
jmrasmus

asked on

ADO connection

This is the first time I am using ADO. Could someone give some sample code to connect to a SQL database? I have a linked table to the sql db and a query to lookup some information from that table. I have done this using DAO (see below), but the sql database is asking for username and password that I do not want the users to see.
Thanks in advance,
Jim


Dim medrec As String
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("qry lookup", dbOpenSnapshot, dbReadOnly)
ASKER CERTIFIED SOLUTION
Avatar of KMAN
KMAN

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KMAN
KMAN

Don't forget to add "Microsoft ActiveX Data Objects..." reference to your app.
Avatar of jmrasmus

ASKER

Kman,
does the myrs recordset have the same properties as the DAO recordset? By that I mean using DAO I can loop through the rescordset, do compairisons to a particular field ie myrs.Fields("Last Name").value="Jones".
Thanks
Jim
Very similar to DAO and many of the same properties are available, and some new ones added.

K
Thanks loads!!!!!