Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: check if recordset is empty


Message #1 by "Carolien Latupeirissa" <clatupeirissa@h...> on Fri, 30 Mar 2001 11:52:50 +0200
Hi there,



I'd like to know how to check if a recordset is empty. If so put some text

on the page and if not display records.



This is one of the codes I tried allready.



I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF is True, or the

current record has been deleted. Requested operation requires a current

record." as an errormessage.



Can anybody push me in the right direction?



Cheers,

Carolien



****************



<%

	Set objRS = Server.CreateObject("ADODB.Recordset")

	strSQL = "SELECT * FROM tblDetails where [OrderID] = " & intOrderID

	Set objRS = objConn.Execute(strSQL)

%>

<table border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

<%

			objRS.MoveFirst

				If objConn.Errors.Count > 0 Then

			Response.Write "This there's no ordered items for this customer<BR>"

				Else



			While Not objRS.EOF

%>

<tr><td><%= objRS.Fields("OrderID") %></td>

<td><%= objRS.Fields("LineItem") %></td>

<td><%= objRS.Fields("Item") %></td>

</tr>



<%

			objRS.MoveNext

			Wend

				End If

%>



****************



Message #2 by "Joe Sabado" <joe.sabado@g...> on Fri, 30 Mar 2001 02:22:51 -0800
if not rs.eof then

    this means recordset is not empty

else

    recordset is empty.



end if

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

From: Carolien Latupeirissa <clatupeirissa@h...>

To: ASP Databases <asp_databases@p...>

Sent: Friday, March 30, 2001 1:52 AM

Subject: [asp_databases] check if recordset is empty





> Hi there,

>

> I'd like to know how to check if a recordset is empty. If so put some text

> on the page and if not display records.

>

> This is one of the codes I tried allready.

>

> I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF is True, or

the

> current record has been deleted. Requested operation requires a current

> record." as an errormessage.

>

> Can anybody push me in the right direction?

>

> Cheers,

> Carolien

>

> ****************

>

> <%

> Set objRS = Server.CreateObject("ADODB.Recordset")

> strSQL = "SELECT * FROM tblDetails where [OrderID] = " & intOrderID

> Set objRS = objConn.Execute(strSQL)

> %>

> <table border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

> <%

> objRS.MoveFirst

> If objConn.Errors.Count > 0 Then

> Response.Write "This there's no ordered items for this customer<BR>"

> Else

>

> While Not objRS.EOF

> %>

> <tr><td><%= objRS.Fields("OrderID") %></td>

> <td><%= objRS.Fields("LineItem") %></td>

> <td><%= objRS.Fields("Item") %></td>

> </tr>

>

> <%

> objRS.MoveNext

> Wend

> End If

> %>

>

Message #3 by "Vincent Drabbe" <vincent@w...> on Fri, 30 Mar 2001 12:38:05 +0200
Use



if RS.EOF and RS.BOF then

  'The recordset RS in empty...

else

  'The recordset RS is not empty

display all the records

end if



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

From: "Carolien Latupeirissa" <clatupeirissa@h...>

To: "ASP Databases" <asp_databases@p...>

Sent: Friday, March 30, 2001 11:52 AM

Subject: [asp_databases] check if recordset is empty





> Hi there,

>

> I'd like to know how to check if a recordset is empty. If so put some text

> on the page and if not display records.

>

> This is one of the codes I tried allready.

>

> I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF is True, or

the

> current record has been deleted. Requested operation requires a current

> record." as an errormessage.

>

> Can anybody push me in the right direction?

>

> Cheers,

> Carolien

>

> ****************

>

> <%

> Set objRS = Server.CreateObject("ADODB.Recordset")

> strSQL = "SELECT * FROM tblDetails where [OrderID] = " & intOrderID

> Set objRS = objConn.Execute(strSQL)

> %>

> <table border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

> <%

> objRS.MoveFirst

> If objConn.Errors.Count > 0 Then

> Response.Write "This there's no ordered items for this customer<BR>"

> Else

>

> While Not objRS.EOF

> %>

> <tr><td><%= objRS.Fields("OrderID") %></td>

> <td><%= objRS.Fields("LineItem") %></td>

> <td><%= objRS.Fields("Item") %></td>

> </tr>

>

> <%

> objRS.MoveNext

> Wend

> End If

> %>

>

Message #4 by Gregory_Griffiths@c... on Fri, 30 Mar 2001 11:50:43 +0100
set results=dbConn.execute(SQLString)



if (results.EOF) then

	' no data

else

	' data

end if



results.close



> -----Original Message-----

> From: clatupeirissa@h... [mailto:clatupeirissa@h...]

> Sent: 30 March 2001 10:53

> To: asp_databases@p...

> Cc: clatupeirissa@h...

> Subject: [asp_databases] check if recordset is empty

> 

> 

> Hi there,

> 

> I'd like to know how to check if a recordset is empty. If so 

> put some text

> on the page and if not display records.

> 

> This is one of the codes I tried allready.

> 

> I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF 

> is True, or the

> current record has been deleted. Requested operation requires 

> a current

> record." as an errormessage.

> 

> Can anybody push me in the right direction?

> 

> Cheers,

> Carolien

> 

> ****************

> 

> <%

> 	Set objRS = Server.CreateObject("ADODB.Recordset")

> 	strSQL = "SELECT * FROM tblDetails where [OrderID] = " 

> & intOrderID

> 	Set objRS = objConn.Execute(strSQL)

> %>

> <table 

> border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

> <%

> 			objRS.MoveFirst

> 				If objConn.Errors.Count > 0 Then

> 			Response.Write "This there's no ordered 

> items for this customer<BR>"

> 				Else

> 

> 			While Not objRS.EOF

> %>

> <tr><td><%= objRS.Fields("OrderID") %></td>

> <td><%= objRS.Fields("LineItem") %></td>

> <td><%= objRS.Fields("Item") %></td>

> </tr>

> 

> <%

> 			objRS.MoveNext

> 			Wend

> 				End If

> %>

> 

Message #5 by "Beena Arjunan" <beena.arjunan@u...> on Fri, 30 Mar 2001 13:20:29
Hi!

Try this ...i have changed your prg. a little..

<%

	Set objRS = Server.CreateObject("ADODB.Recordset")

	strSQL = "SELECT * FROM tblDetails where [OrderID] = " & intOrderID

	Set objRS = objConn.Execute(strSQL)

%>

<table border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

<%

			on error resume next	

			objRS.MoveFirst

				If objRS.eof Then  

			Response.Write "This there's no ordered items for 

this customer<BR>"

				Else



			While Not objRS.EOF

%>

<tr><td><%= objRS.Fields("OrderID") %></td>

<td><%= objRS.Fields("LineItem") %></td>

<td><%= objRS.Fields("Item") %></td>

</tr>



<%

			objRS.MoveNext

			Wend

				End If

%>





hope that helps,

Beena.











> Hi there,

> 

> I'd like to know how to check if a recordset is empty. If so put some 

text

> on the page and if not display records.

> 

> This is one of the codes I tried allready.

> 

> I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF is True, or 

the

> current record has been deleted. Requested operation requires a current

> record." as an errormessage.

> 

> Can anybody push me in the right direction?

> 

> Cheers,

> Carolien

> 

> ****************

> 

> <%

> 	Set objRS = Server.CreateObject("ADODB.Recordset")

> 	strSQL = "SELECT * FROM tblDetails where [OrderID] = " & intOrderID

> 	Set objRS = objConn.Execute(strSQL)

> %>

> <table border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

> <%

> 			objRS.MoveFirst

> 				If objConn.Errors.Count > 0 Then

> 			Response.Write "This there's no ordered items for 

this customer<BR>"

> 				Else

> 

> 			While Not objRS.EOF

> %>

> <tr><td><%= objRS.Fields("OrderID") %></td>

> <td><%= objRS.Fields("LineItem") %></td>

> <td><%= objRS.Fields("Item") %></td>

> </tr>

> 

> <%

> 			objRS.MoveNext

> 			Wend

> 				End If

> %>

> 

> ****************

> 

Message #6 by "Tomm Matthis" <matthis@b...> on Fri, 30 Mar 2001 08:46:18 -0500
You can check like this (regardless of the cursortype you use):



If NOT (objRS.BOF AND objRS.EOF) then

	' you got records

Else

	' you don't got records

End If



Tomm



> -----Original Message-----

> From: Carolien Latupeirissa [mailto:clatupeirissa@h...]

> Sent: Friday, March 30, 2001 4:53 AM

> To: ASP Databases

> Subject: [asp_databases] check if recordset is empty

>

>

> Hi there,

>

> I'd like to know how to check if a recordset is empty. If so put some 

text

> on the page and if not display records.

>

> This is one of the codes I tried allready.

>

> I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF is

> True, or the

> current record has been deleted. Requested operation requires a 

current

> record." as an errormessage.

>

> Can anybody push me in the right direction?

>

> Cheers,

> Carolien

>

> ****************

>

> <%

> 	Set objRS =3D Server.CreateObject("ADODB.Recordset")

> 	strSQL =3D "SELECT * FROM tblDetails where [OrderID] =3D " & 

intOrderID

> 	Set objRS =3D objConn.Execute(strSQL)

> %>

> <table 

border=3D"1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

> <%

> 			objRS.MoveFirst

> 				If objConn.Errors.Count > 0 Then

> 			Response.Write "This there's no ordered

> items for this customer<BR>"

> 				Else

>

> 			While Not objRS.EOF

> %>

> <tr><td><%=3D objRS.Fields("OrderID") %></td>

> <td><%=3D objRS.Fields("LineItem") %></td>

> <td><%=3D objRS.Fields("Item") %></td>

> </tr>

>

> <%

> 			objRS.MoveNext

> 			Wend

> 				End If

> %>

>

> ****************

>

>

> 
Message #7 by samimer@h... on Fri, 30 Mar 2001 22:34:13
Carolien,



Whenever you get that message it means that you are doing a move operation 

on an emtpy recordset. Before you do a movefirst, you will need to check 

if the operation is valid. Also in an emtpy recordset both EOF and BOF are 

true.Keeping that in mind, you can do it this way (it is one of the ways)



'After opening your recordset

If NOT (objRS.EOF AND objRS.BOF) Then

   objRS.MoveFirst

   Do Until objRS.EOF

     'do all the processing in here

      

      objRS.MoveNext

   Loop

End If





Hope it helps you.





> Hi there,

> 

> I'd like to know how to check if a recordset is empty. If so put some 

text

> on the page and if not display records.

> 

> This is one of the codes I tried allready.

> 

> I'm getting: "ADODB.Recordset (0x800A0BCD) Either BOF or EOF is True, or 

the

> current record has been deleted. Requested operation requires a current

> record." as an errormessage.

> 

> Can anybody push me in the right direction?

> 

> Cheers,

> Carolien

> 

> ****************

> 

> <%

> 	Set objRS = Server.CreateObject("ADODB.Recordset")

> 	strSQL = "SELECT * FROM tblDetails where [OrderID] = " & intOrderID

> 	Set objRS = objConn.Execute(strSQL)

> %>

> <table border="1"><tr><td>OrderID</td><td>LineItem</td><td>Item</td></tr>

> <%

> 			objRS.MoveFirst

> 				If objConn.Errors.Count > 0 Then

> 			Response.Write "This there's no ordered items for 

this customer<BR>"

> 				Else

> 

> 			While Not objRS.EOF

> %>

> <tr><td><%= objRS.Fields("OrderID") %></td>

> <td><%= objRS.Fields("LineItem") %></td>

> <td><%= objRS.Fields("Item") %></td>

> </tr>

> 

> <%

> 			objRS.MoveNext

> 			Wend

> 				End If

> %>

> 

> ****************

> 


  Return to Index