Thread: Reading a table
View Single Post
  #3 (permalink)  
Old December 30th, 2004, 09:05 AM
mmcdonal mmcdonal is offline
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

How about this...

'==============================
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
strUserName = "username"
strPassword = "password"

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=YourDSNNameHere;", strUserName, strPassword
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM tblYourTableNameHere" , _
objConnection, adOpenStatic, adLockOptimistic

Do While Not objRecordSet.EOF
   <Your statements>
Loop

objRecordset.Close
objConnection.Close
'============================================

This requires that you set up a system DSN first. I can give you the code to automate that, or you can do it manually.

Hope this helps.


mmcdonal
Reply With Quote