RecordCount -1 
Author Message
 RecordCount -1

Hi!

I am tring use ADO to access data from SQL Server 6.5 .
The source code as...

Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open "DATABASE=Pubs;DSN=test;uid=sa;password="
sqlStream = "Select * From Books Order"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.ActiveConnection = conn
Rs.CursorType = adOpenStatic
Rs.LockType = adLockPessimistic
Rs.Source = sqlStream
Rs.Open

the result of Rs.RecordCount is -1, but the table "Books"
have 10 records.

help me! please and thanks

Mos



Mon, 03 Sep 2001 03:00:00 GMT  
 RecordCount -1
RecordCount returns -1 when ADO can't determine the numbers of Recordsets.

If the recordset object supports approximate positioning or bookmarks that
is Supports(ApproxPosition)
or Supports(adBookmark), respectivly returns true. you can use the
RecordCount.

If the Recordset object does not support approximate positioning, all the
records will have to be retrived and counted
to return an accurate RecordCount value.

I belived that SQL Server 6.5 supported this. Checkout if
Supports(ApproxPosition) or Supports(adBookmark) returns true
if it does return false, then you might need to check out the knowledge base
to see if it might be a bug or limitation of SQL server 6.5

/ Kai Thorsrud

Quote:

>Hi!

>I am tring use ADO to access data from SQL Server 6.5 .
>The source code as...

>Set Conn = Server.CreateObject("ADODB.Connection")
>conn.Open "DATABASE=Pubs;DSN=test;uid=sa;password="
>sqlStream = "Select * From Books Order"
>Set Rs = Server.CreateObject("ADODB.Recordset")
>Rs.ActiveConnection = conn
>Rs.CursorType = adOpenStatic
>Rs.LockType = adLockPessimistic
>Rs.Source = sqlStream
>Rs.Open

>the result of Rs.RecordCount is -1, but the table "Books"
>have 10 records.

>help me! please and thanks

>Mos



Mon, 03 Sep 2001 03:00:00 GMT  
 RecordCount -1
You must use a dynamic cursor located on the client in order to retrieve the
recordcount. Before you open your connection add the following:

conn.CursorLocation = adUseClient

and for your cursor type change from adOpenStatic to adOpenDynamic.

HTH,

Ted White
Intelesoft
http://www.intelesoft.com

Quote:

>Hi!

>I am tring use ADO to access data from SQL Server 6.5 .
>The source code as...

>Set Conn = Server.CreateObject("ADODB.Connection")
>conn.Open "DATABASE=Pubs;DSN=test;uid=sa;password="
>sqlStream = "Select * From Books Order"
>Set Rs = Server.CreateObject("ADODB.Recordset")
>Rs.ActiveConnection = conn
>Rs.CursorType = adOpenStatic
>Rs.LockType = adLockPessimistic
>Rs.Source = sqlStream
>Rs.Open

>the result of Rs.RecordCount is -1, but the table "Books"
>have 10 records.

>help me! please and thanks

>Mos



Mon, 03 Sep 2001 03:00:00 GMT  
 RecordCount -1
Hi!
    I solved this problem, just including content file
    "/ASPSAMP/SAMPLES/ADOVBS.INC".
    then, every thing is OK!

Mos

Mos Lin Wrote...

Quote:
>Hi!

>I am tring use ADO to access data from SQL Server 6.5 .
>The source code as...

>Set Conn = Server.CreateObject("ADODB.Connection")
>conn.Open "DATABASE=Pubs;DSN=test;uid=sa;password="
>sqlStream = "Select * From Books Order"
>Set Rs = Server.CreateObject("ADODB.Recordset")
>Rs.ActiveConnection = conn
>Rs.CursorType = adOpenStatic
>Rs.LockType = adLockPessimistic
>Rs.Source = sqlStream
>Rs.Open

>the result of Rs.RecordCount is -1, but the table "Books"
>have 10 records.

>help me! please and thanks

>Mos



Tue, 04 Sep 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. DAO Recordcount vs. ADO Recordcount

2. RS.MoveLast and RS.RecordCount strategy

3. If (Recordcount)=1 then

4. RecordCount is +1

5. RecordCount using ADO (Access2000)

6. If Me.Recordset.RecordCount = 0 - access 97

7. DAO--BOF and EOF vs recordcount = 0

8. recordcount problem

9. RecordCount property

10. recordcount of recordset

11. RecordCount changes itself?

12. DAO Recordset returning incorrect recordcount

 

 
Powered by phpBB® Forum Software