Advertisement

08.07.2008 at 10:16AM PDT, ID: 23630205 | Points: 500
[x]
Attachment Details

How to use check if BOF and EOF is true when a stored procedure is used to return the recordset?

Asked by endrec in Active Server Pages (ASP), VB Script

Tags: ,

I have a page that uses a querystring to filter the dispaly to one item in VBScript and ASP classic.  When the user enters a value for the QueryString (ImageID) that is not valid I would like to display some text informing them of that, however the regular BOF and EOF methods are not working as a stored proceduring is being used to return the recordset.  When no results are returned it seems that you cannot use EOF or BOF to display content conditionally.

The error I receive any time I even try to use BOF or EOF when the stored procedure does not return any results is:

 ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

How could I use BOF and EOF or something similar to display content conditionally when the stored procedure ?

If I added: cmdGetImage.Parameters.Append cmdGetImage.CreateParameter("@RETURN_VALUE", 3, 4) to the code below how could I store the return value to a variable that can be accessed later in the page.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
Dim cmdGetImage__ImageID
cmdGetImage__ImageID = "1"
if(Request("ImageID") <> "") then
	cmdGetImage__ImageID = Request("ImageID")
	cmdGetImage__ImageID = Replace(cmdGetImage__ImageID, "'", "")
	if IsNumeric(cmdGetImage__ImageID) = False then
		cmdGetImage__ImageID = 0
	else
		Session("ImageID") = cmdGetImage__ImageID
	end if
else
	Response.Redirect("/ImageAgreement/")
end if
 
Dim cmdGetImage__IsActive
cmdGetImage__IsActive = "1"
'if(Request("IsActive") <> "") then cmdGetImage__IsActive = Request("IsActive")
 
Dim cmdGetImage__NTUsername
cmdGetImage__NTUsername = "333"
if(Session("NTUsername") <> "") then cmdGetImage__NTUsername = Session("NTUsername")
 
%>
<%
 
set cmdGetImage = Server.CreateObject("ADODB.Command")
cmdGetImage.ActiveConnection = MM_ConnectionImageAgreement_STRING
cmdGetImage.CommandText = "dbo.agr_ViewImage"
cmdGetImage.Parameters.Append cmdGetImage.CreateParameter("@ImageID", 20, 1,100,cmdGetImage__ImageID)
cmdGetImage.Parameters.Append cmdGetImage.CreateParameter("@IsActive", 16, 1,1,cmdGetImage__IsActive)
cmdGetImage.Parameters.Append cmdGetImage.CreateParameter("@NTUsername", 200, 1,150,cmdGetImage__NTUsername)
cmdGetImage.CommandType = 4
cmdGetImage.CommandTimeout = 0
cmdGetImage.Prepared = true
set rsImage = cmdGetImage.Execute
rsImage_numRows = 0
%>
 
 
'Following code gives an error when the ImageID is not valid
If rsImage.EOF Or Not rsImage.BOF Then
 strTitle = Trim( rsImage.Fields.Item("Title").Value )
End If
[+][-]08.07.2008 at 10:22AM PDT, ID: 22183167

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 12:21PM PDT, ID: 22184338

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 01:12PM PDT, ID: 22184883

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 01:19PM PDT, ID: 22184946

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 01:30PM PDT, ID: 22185050

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 01:32PM PDT, ID: 22185084

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.07.2008 at 06:33PM PDT, ID: 22186914

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.08.2008 at 06:06AM PDT, ID: 22189467

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.08.2008 at 08:19AM PDT, ID: 22190708

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2008 at 12:19PM PDT, ID: 22197351

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628