473,661 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored Procedure call from ASP page problem

I need to call an stored procedure from an asp script, I don't need to
do an Output parameter, only input parameters on 3 vars, but I get a
"BOF EOF not true or record has been deleted" error when trying to
call the page with the correct querystrings. The stored procedure
looks like it's properly called , as i tried misspelling the stored
procedure in the "CmdSP.CommandT ext = "resultsSP" " line, and the
error prompted no such stored procedure. The connection string is
correct:
'''''''''

<% Dim countyQ,stateQ, categQ
countyQ = request.queryst ring("county")
stateQ = request.queryst ring("state")
categQ = request.queryst ring("category" )
%>
<%
Dim CmdSP
Dim rset
Dim adCmdSPStoredPr oc
Dim adParamReturnVa lue
Dim adParaminput
Dim adParamOutput
Dim adInteger
Dim iVal
Dim oVal
Dim adoField
Dim adVarChar

adCmdSPStoredPr oc = 4
adParamReturnVa lue = 4
adParaminput = 1
adParamOutput = 2
adInteger = 3
adVarChar = 200

iVal = 5
oVal = 3
Set CmdSP = Server.CreateOb ject("ADODB.Com mand")
CmdSP.ActiveCon nection = conn
CmdSP.CommandTe xt = "resultsSP"
CmdSP.CommandTy pe = adCmdSPStoredPr oc
'-- define the first parameter - the one the procedure will return
'-- the calls are:
'-- CmdSP.Parameter s.Append: append this parameter to the
collection for this command object
'-- CmdSP.CreatePar ameter(): creates the parameter using the
values given:
'-- "@countyQ" is the name of the parameter for later reference
'-- adVarChar (value = 200) indicates this parameter is a
string datatype
'-- adParamInput (value = 1) indicates this parameter is for
input
'-- 20 is the size of the string in characters
'-- "M" is an arbitrary initial value for this parameter
CmdSP.Parameter s.Append CmdSP.CreatePar ameter("@county Q", adVarChar,
adParaminput, 40, "")

CmdSP.Parameter s.Append CmdSP.CreatePar ameter("@stateQ ", adVarChar,
adParaminput, 2, "")

CmdSP.Parameter s.Append CmdSP.CreatePar ameter("@categQ ", adVarChar,
adParaminput, 25, "")


Set rset = CmdSP.Execute
%>
<%If Not rset.BOF Then%>
<%
Do While Not rset.EOF%>

<br><%= rset("company") %><br>
<%= rset("city") %>&nbsp;<%= rset("state") %<br>
<%= rset("phone") %><br>
<i><%= rset("descript" ) %>&nbsp;</i><br>
<% rset.MoveNext
Loop
%>
<%End If%>

''here is the sproc creation

CREATE PROCEDURE resultsSP
@countyQ varchar(40),
@stateQ varchar(2),
@categQ varchar(25)
AS
BEGIN
SELECT * FROM general WHERE county='" + @countyQ + "' and state='" +
@stateQ + "' and category='" + @categQ + "' order by company
end

'' the resulting error on the asp page in question:
ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/auto-results.asp, line 0

'''''
TIA
netsports

Jun 4 '07 #1
3 4202
..Net Sports wrote:
I need to call an stored procedure from an asp script, I don't
need to do an Output parameter...

...CREATE PROCEDURE resultsSP
@countyQ varchar(40),
@stateQ varchar(2),
@categQ varchar(25)
AS
BEGIN
SELECT * FROM general WHERE county='" + @countyQ + "' and state='" +
@stateQ + "' and category='" + @categQ + "' order by company
end
Seriously, there is no need to use a command object here. This will suffice:

Set rset = CreateObject("A DODB.Recordset" )
CmdSP.resultsSP countyQ, stateQ, categQ, rset

Then...
<%Do While Not rset.EOF%>

<br><%= rset("company") %><br>
<%= rset("city") %>&nbsp;<%= rset("state") %<br>
<%= rset("phone") %><br>
<i><%= rset("descript" ) %>&nbsp;</i><br>
<% rset.MoveNext
Loop
%>
See the section labeled, "Execute a stored procedure as a native method of a
Connection object":
http://msdn.microsoft.com/library/en...connection.asp

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jun 4 '07 #2
..Net Sports wrote:
<snip>
>
''here is the sproc creation

CREATE PROCEDURE resultsSP
@countyQ varchar(40),
@stateQ varchar(2),
@categQ varchar(25)
AS
BEGIN
SELECT * FROM general WHERE county='" + @countyQ + "' and state='" +
http://www.aspfaq.com/show.asp?id=2096
@stateQ + "' and category='" + @categQ + "' order by company
end
Have you tried running this procedure in query analyzer? It looks like
you are concatenating strings to create a dynamic sql statement, but you
never execute it ...? If I was writing this procedure it would look like
this:

CREATE PROCEDURE resultsSP
@countyQ varchar(40),
@stateQ varchar(2),
@categQ varchar(25)
AS
BEGIN
/*the following line prevents informational messages from
being returned as extra resultsets*/
/*************** *************** ******
SET NOCOUNT ON
*************** *************** *******/
SELECT company,city,ph one,descript
FROM general WHERE county= @countyQ and state=
@stateQ and category= @categQ order by company
end
Also, you are going to entirely too much trouble to execute this
procedure. Without output parameters, and with no need to read a return
parameter value, an explicit Command object is not needed. Try this:
Oh wait ... it appears Dave has already touched on this. See his reply.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 4 '07 #3
..Net wrote on Mon, 04 Jun 2007 09:43:27 -0700:
I need to call an stored procedure from an asp script, I don't need to
do an Output parameter, only input parameters on 3 vars, but I get a
"BOF EOF not true or record has been deleted" error when trying to
call the page with the correct querystrings. The stored procedure
looks like it's properly called , as i tried misspelling the stored
procedure in the "CmdSP.CommandT ext = "resultsSP" " line, and the
error prompted no such stored procedure. The connection string is
correct:
'''''''''
''here is the sproc creation

CREATE PROCEDURE resultsSP

@countyQ varchar(40),
@stateQ varchar(2),
@categQ varchar(25)

AS
BEGIN
SELECT * FROM general WHERE county='" + @countyQ + "' and state='" +
@stateQ + "' and category='" + @categQ + "' order by company
end
This is wrong. When using parameters like this, you don't treat them as
strings to concatenate into the query, change it to this:

SELECT * FROM general WHERE county= @countyQ and state= @stateQ and
category= @categQ order by company
I think the problem you were having is that you were testing for rst.BOF,
but your SP wasn't even returning a recordset that you could test for BOF.

Dan
Jun 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7493
by: Richard Morey | last post by:
Hi.. I have written a stored procedure that take 5 - 8 minutes to fully execute.. I wrote this routine as a stored procedure because I started to create all the functionality via ASP but I kept getting time out errors on my ASP page. The problem is that when I call the stored procedure from the ASP page the server waits for the procedure to complete before returning the ASP page.. Is there any way to avoid this? I would like the user to...
3
22129
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
6
6757
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to call the stored procedure and retrieve data from AS/400. The problem is, that when I finally run my VB code, it just hangs. But when I call the same stored procedure from "pure" SQL - it works perfect. (I evaluate Aqua Data Studio 3.7) What I...
3
1764
by: Bilbo | last post by:
I have a a headscratcher here: I have a form that when submitted should do 2 things when a user enters data and then clicks the Add button. Here goes: 1. Call a stored procedure called AddCompany to insert the company name from the Company Name textbox into the COMPANY table and return the @@IDENTITY of the company name just input into the database back to a label on the form. THIS IS WORKING.
7
2215
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL tabel. I know the SP works, because a smalldatetime-field in the database is changed. I've tried to disable viewstate on all textbox controls. Any ideas to solve this problem.
2
1434
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! **************************************************************************************************** Original Question: -------------------- Has anyone called a COBOL subroutine using COBOL CALL from a COBOL/DB2
0
19272
by: IamtheEvster | last post by:
Hi All, I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am unable to call a MySQL stored procedure that returns output parameters using mysql, mysqli, or PDO. I'm having a hell of a time with it... The following comes from phpinfo(): PHP Version: 5.1.2 mysql Client API version: 5.0.18 mysqli Client API version: 5.0.18
1
2284
by: central_scrutinizer | last post by:
I have an ASP that has been working fine for several months, but it suddenly broke. I wonder if windows update has installed some security patch that is causing it. The problem is that I am calling a stored procedure via an ASP (classic, not .NET) , but nothing happens. The procedure doesn't work, and I don't get any error messages. I've tried dropping and re-creating the user and permissions, to no avail. If it was a permissions...
7
5840
by: eholz1 | last post by:
Hello PHP group, Could someone help me out? I have PHP 5.2, Apache 2.0, and MySQL 5.0 running on Linux (Redhat Fedora Core 6). All that works fine. I would like to be able to "call" a stored procedure from a PHP program, and run a stored procedure. I have yet to figure out the proper way to do this. My stored procedures work fine from the mysql command line using syntax: "call sp_min_record (101);"
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.