Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make RecordCount property of the Recordset return the right value (not -1)?

Data Access

How to make RecordCount property of the Recordset return the right value (not -1)?

by  medic  Posted    (Edited  )

Answer:
Create your recordset as client-side cursor.
Example:[tt]
[color blue]<%
Set objCN = Server.CreateObject("ADODB.Connection")
ConnStr = "Provider=VFPOLEDB.1;"+_
"Data Source="+Server.MapPath(".")

objCN.Open (ConnStr)
Set objRS = Server.CreateObject("ADODB.Recordset")

objRS.CursorLocation = 3 [green]' Client-side[/green]

objRS.Open "select * from MyTable", objCN
Response.Write "Total number of records = " & objRS.RecordCount

objRS.Close
objCN.Close
%>
[/color]
[/tt]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top