General information
Category:
Coding, syntax & commands
Hi All:
I want to loop through the recordset and the the values for a field in my code,however when I execute my program, the record count is -1. I know I have at least seven records in my table. Below is my code. Can someone please show me how to loop through the records and extract the values for a given field in a table.
Thanks
MA
Dim oDataComm As ADODB.Connection
Dim oRecSet As New ADODB.Recordset
Dim i%, MaxFields%
Dim lPhone As String
' Make connection to DB
Set oDataComm = New ADODB.Connection
oDataComm.Connectionstring = "DSN=ctcore"
oDataComm.Open
oRecSet.Open "SELECT * FROM Phone", oDataComm
MaxFields = oRecSet.RecordCount ***I am getting Maxfields as -1***
For i = 1 To MaxFields
lPhone = oResSet.Recordset.Fields(i).Value
Next i
oRecSet.Close
oDataComm.Close
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only