Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Empty Recordset with ADO Command Object


Message #1 by "Reginald Dawson" <rdawson@w...> on Sun, 10 Dec 2000 21:25:39 -0000
Greetings,



I am having a bit of trouble with the ADO Command Object again. 

Apparently when I make a query with the Command Object, it always return a

recordcount of -1 but contains data in the recordset!!  Here is an example

of my code:

-------------------------------------------------

query = "SELECT ID, PASSWORD FROM [USERINFO] WHERE UID = 12345"

	set rs = Server.CreateObject("ADODB.Command")

	rs.ActiveConnection = Strconn  '--- my connection string

	rs.CommandText = query

	rs.CommandType = &H0001        '--- abbrv. from adovbs.inc

	set recs = rs.Execute

	set rs = nothing

	

	Response.write(recs.recordcount)

        Response.write(recs.Fields("ID"))

        Response.write(recs.Fields("PASSWORD"))

-------------------------------------------------

From the above code, the recordcount appears as -1 while the ID and

password fields do contain data!  Why could there be a -1 recordcount in

an actual recordset??



Thanks for the help and insight,



Reginald Dawson

Message #2 by =?iso-8859-1?Q?H=E5kan_Frennesson?= <hakan@c...> on Mon, 11 Dec 2000 11:21:22 +0100
Hi!



Read this



http://www.learnasp.com/learn/dbcount.asp



You got to have the right cursortype and I think that is your problem.



HTH





Hakan



-----Original Message-----

From: Reginald Dawson [mailto:rdawson@w...]

Sent: den 10 december 2000 22:26

To: ASP Databases

Subject: [asp_databases] Empty Recordset with ADO Command Object



Greetings,



I am having a bit of trouble with the ADO Command Object again.

Apparently when I make a query with the Command Object, it always return a

recordcount of -1 but contains data in the recordset!!  Here is an example

of my code:

-------------------------------------------------

query = "SELECT ID, PASSWORD FROM [USERINFO] WHERE UID = 12345"

        set rs = Server.CreateObject("ADODB.Command")

        rs.ActiveConnection = Strconn  '--- my connection string

        rs.CommandText = query

        rs.CommandType = &H0001        '--- abbrv. from adovbs.inc

        set recs = rs.Execute

        set rs = nothing



        Response.write(recs.recordcount)

        Response.write(recs.Fields("ID"))

        Response.write(recs.Fields("PASSWORD"))

-------------------------------------------------



From the above code, the recordcount appears as -1 while the ID and

password fields do contain data!  Why could there be a -1 recordcount in

an actual recordset??



Thanks for the help and insight,



Reginald Dawson





Message #3 by Imar Spaanjaars <Imar@S...> on Mon, 11 Dec 2000 09:13:13 +0100
Hi there,



Check out Ken's site to find answers to these questions:



Why recordcount returns -1

http://www.adopenstatic.com/faq/recordcounterror.asp



and what alternatives you have to get the correct count

http://www.adopenstatic.com/faq/recordcountalternatives.asp



Imar





At 09:25 PM 12/10/2000 +0000, you wrote:

>Greetings,

>

>I am having a bit of trouble with the ADO Command Object again.

>Apparently when I make a query with the Command Object, it always return a

>recordcount of -1 but contains data in the recordset!!  Here is an example

>of my code:

>-------------------------------------------------

>query = "SELECT ID, PASSWORD FROM [USERINFO] WHERE UID = 12345"

>         set rs = Server.CreateObject("ADODB.Command")

>         rs.ActiveConnection = Strconn  '--- my connection string

>         rs.CommandText = query

>         rs.CommandType = &H0001        '--- abbrv. from adovbs.inc

>         set recs = rs.Execute

>         set rs = nothing

>

>         Response.write(recs.recordcount)

>         Response.write(recs.Fields("ID"))

>         Response.write(recs.Fields("PASSWORD"))

>-------------------------------------------------

> From the above code, the recordcount appears as -1 while the ID and

>password fields do contain data!  Why could there be a -1 recordcount in

>an actual recordset??

>

>Thanks for the help and insight,

>

>Reginald Dawson

>

Message #4 by =?iso-8859-1?Q?H=E5kan_Frennesson?= <hakan@c...> on Mon, 11 Dec 2000 11:23:08 +0100
Hi again!



Or you could use GetRows instead.



http://www.learnasp.com/learn/dbtablegetrow.asp





Hakan





-----Original Message-----

From: Reginald Dawson [mailto:rdawson@w...]

Sent: den 10 december 2000 22:26

To: ASP Databases

Subject: [asp_databases] Empty Recordset with ADO Command Object



Greetings,



I am having a bit of trouble with the ADO Command Object again.

Apparently when I make a query with the Command Object, it always return a

recordcount of -1 but contains data in the recordset!!  Here is an example

of my code:

-------------------------------------------------

query = "SELECT ID, PASSWORD FROM [USERINFO] WHERE UID = 12345"

        set rs = Server.CreateObject("ADODB.Command")

        rs.ActiveConnection = Strconn  '--- my connection string

        rs.CommandText = query

        rs.CommandType = &H0001        '--- abbrv. from adovbs.inc

        set recs = rs.Execute

        set rs = nothing



        Response.write(recs.recordcount)

        Response.write(recs.Fields("ID"))

        Response.write(recs.Fields("PASSWORD"))

-------------------------------------------------

From the above code, the recordcount appears as -1 while the ID and

password fields do contain data!  Why could there be a -1 recordcount in

an actual recordset??



Thanks for the help and insight,



Reginald Dawson




  Return to Index