|
-
August 16th, 2005, 10:41 AM
#1
ADORecordset.RecordCount = -1
Hi everyone,
Would you please tell me why this is happening? I use ADO with MS Access 2002 and here is what I do:
'Declarations
Private adoConn As New ADODB.Connection
Private adoRS As New ADODB.Recordset
Private StringCnn As String
Private AccessCnn As String
.......
'make the connection for the DB
AccessCnn = "DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=EmailData.mdb;" & "DefaultDir=" & App.Path + "\" & ";" & "UID=admin;PWD=;"
StringCnn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\EmailData.mdb;Persist Security Info=False;"
'''These are the codes from by Sub
sSource = "SELECT * FROM Server" 'Server is the table name
adoConn.Open StringCnn & App.Path & "\EmailData.mdb" 'Emaildata is the DB file name
adoRS.Open sSource, adoConn, adOpenDynamic, adLockOptimistic
With adoRS
If .RecordCount Then
.MoveFirst
Do While Not .EOF
...........I do lots of things in here
Loop
End If
.Close
Set adoRS = Nothing
adoConn.Close
Set adoConn = Nothing
End With
I have 2 records in table "Server" but .RecordCount gives me -1, this is NOT right. Then I deleted ALL records from table "Server" but now .RecordCount still gives me -1.
What is wrong with it? How to fix it?
Thanks,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|