p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: ADODB.Command and Empty Recordsets Error


Message #1 by "Reginald Dawson" <rdawson@w...> on Wed, 6 Dec 2000 18:23:33 -0000
Please advise,



I have a problem with a SQL statement I am running.  Whenever I make the

command with the Command Object, it returns an empty recordset

( eg : "rs.EOF is False" ) yet when I make the same command with the

Recordset Object it returns a valid recordcount

( eg. "rs.Recordcount = 1").  Below is the code snippet for the SQL

Command

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

query = "SELECT PHONE, EMAIL, MEMBNAME FROM [INFO] WHERE MEMBNUM = "305"

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

	rs.ActiveConnection = conn

	rs.CommandText = query

	rs.CommandType = &H0001

	set recs = rs.Execute

        set rs = nothing

	  if recs.EOF = False then ' ... do something

	    else ' ...do something else

          End If

        set recs = nothing

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

Does anyone know why this might be?

Thanks for any help anyone can provide and for your time,

Reginald Dawson

Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 06 Dec 2000 19:31:59 +0100
mmmm, I think it's the other way around.

EOF stands for End Of File (from the old file-based days, I guess), so when 

the recordset is empty, EOF returns true:



if recs.EOF then

         ' No records found

else

         ' There are records, so process them.

end if



HtH



Imar





At 06:23 PM 12/6/2000 +0000, you wrote:

>Please advise,

>

>I have a problem with a SQL statement I am running.  Whenever I make the

>command with the Command Object, it returns an empty recordset

>( eg : "rs.EOF is False" ) yet when I make the same command with the

>Recordset Object it returns a valid recordcount

>( eg. "rs.Recordcount = 1").  Below is the code snippet for the SQL

>Command

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

>query = "SELECT PHONE, EMAIL, MEMBNAME FROM [INFO] WHERE MEMBNUM = "305"

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

>         rs.ActiveConnection = conn

>         rs.CommandText = query

>         rs.CommandType = &H0001

>         set recs = rs.Execute

>         set rs = nothing

>           if recs.EOF = False then ' ... do something

>             else ' ...do something else

>           End If

>         set recs = nothing

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

>Does anyone know why this might be?

>Thanks for any help anyone can provide and for your time,

>Reginald Dawson

>



Message #3 by "DrClean" <Wayne@d...> on Wed, 6 Dec 2000 21:40:20 -0000
Hi,



If rs.EOF is false then you have a record because you're not at the end of

the file. Hence when you ask for a record count you have at least one

record.



In other words it appears you're getting the correct response. Sorry!



Wayne



www.DrClean.co.uk





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

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

Sent: 06 December 2000 18:24

To: ASP Databases

Subject: [asp_databases] ADODB.Command and Empty Recordsets Error





Please advise,



I have a problem with a SQL statement I am running.  Whenever I make the

command with the Command Object, it returns an empty recordset

( eg : "rs.EOF is False" ) yet when I make the same command with the

Recordset Object it returns a valid recordcount

( eg. "rs.Recordcount = 1").  Below is the code snippet for the SQL

Command

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

query = "SELECT PHONE, EMAIL, MEMBNAME FROM [INFO] WHERE MEMBNUM = "305"

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

	rs.ActiveConnection = conn

	rs.CommandText = query

	rs.CommandType = &H0001

	set recs = rs.Execute

        set rs = nothing

	  if recs.EOF = False then ' ... do something

	    else ' ...do something else

          End If

        set recs = nothing

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

Does anyone know why this might be?

Thanks for any help anyone can provide and for your time,

Reginald Dawson




  Return to Index