Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fileds value
Message
 
To
All
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Fileds value
Miscellaneous
Thread ID:
00895947
Message ID:
00895947
Views:
53
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
Map
View

Click here to load this message in the networking platform