ADO RecordCount -1
- From: "greg4168@xxxxxxxxx" <greg4168@xxxxxxxxx>
- Date: 26 Aug 2005 13:21:52 -0700
Hi - I'm stumped on using ADO to count the number of rows in a SQL
Server table. I'm using VB6. I've populated the connection fields
elsewhere, and can see that it is actually reading the table (by
checking the returned values while debugging), but I'm getting the
infamous "-1" as a return from the .recordcount method. I'm trying to
populate 'numrec' with the count of rows.
Thanks in advance for any help you can provide.
Below is the specific code snippet, there is more code before and after
of course, but this is the section I'm having trouble with:
dim numrecs as long
strConnect = "Provider=SQLOLEDB.1" _
& ";User ID=" & txtUID _
& ";Password=" & txtPWD _
& ";Initial Catalog=" & txtDatabase _
& ";Data Source=" & txtServer
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strConnect
End With
Set rst = New ADODB.Recordset
With rst
.Open Source:=txtTable, _
ActiveConnection:=cnn, _
CursorType:=adOpenKeyset, _
LockType:=adLockOptimistic
If Not .BOF And Not .EOF Then
.MoveLast
numrecs = .RecordCount
End If
.
- Follow-Ups:
- Re: ADO RecordCount -1
- From: Victor Koch
- Re: ADO RecordCount -1
- Prev by Date: Upper limit to data returned by an ADO recordset
- Next by Date: Re: ADO RecordCount -1
- Previous by thread: Upper limit to data returned by an ADO recordset
- Next by thread: Re: ADO RecordCount -1
- Index(es):
Relevant Pages
|
|