How can I get a record number from any table or query in SQL Server through ADO recordset, but CursorLocation in server side. There are some way to know it?
Printable View
How can I get a record number from any table or query in SQL Server through ADO recordset, but CursorLocation in server side. There are some way to know it?
Do you mean record count (total number of records) or the position of current record of your server-side cursor? Here is the answer to both:
Code:'Record Count
If rsSCIROCCO.Supports(adApproxPosition) Or rsSCIROCCO.Supports(adBookmark) Then
RecordCount = rsSCIROCCO.RecordCount
End If
Code:'Current Position
If rsSCIROCCO.Supports(adApproxPosition) Then
AbsolutePosition = rsSCIROCCO.AbsolutePosition
End If
If the recordset is forward only you can use the following to get a recordcount
VB Code:
Dim rs As New ADODB.Recordset Dim vCount() As Variant Dim lCount As Long rs.Open “SELECT * FROM Test”, “DSN=Test”, , , adCmdText vCount() = rs.GetRows() lCount = UBound(vCount, 2) + 1 Debug.Print lCount
Hope this helps
:wave: :thumb: :wave: