473,569 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Output parameters

I am trying to return an output parameter to my code on executing a
stored procedure. In Query Analyzer, it works with no problem, but when
I run my ASP code below, the output parameter never seems to return
anything. Can anybody help?

Dim cmdNewCampaign, rsNewCampaign, intNumber
Const adCmdStoredProc = &H0004
Const adParamInput = &H0001
Const adParamOutput = &H0002
Const adVarChar = 200
Const adInteger = 3

Set cmdNewCampaign = Server.CreateOb ject ("ADODB.Command ")
cmdNewCampaign. ActiveConnectio n = strConnection
cmdNewCampaign. CommandText = "AddNewCampaign "
cmdNewCampaign. CommandType = adCmdStoredProc
cmdNewCampaign. Parameters.Appe nd
cmdNewCampaign. CreateParameter ("@CampaignName ",adVarChar,adP aramInput
,100, request("Campai gnName"))
cmdNewCampaign. Parameters.Appe nd
cmdNewCampaign. CreateParameter ("@CampaignID", adInteger,adPar amOutput)
Set rsNewCampaign = cmdNewCampaign. Execute

intNumber = cmdNewCampaign. Parameters("@Ca mpaignID")


*** Sent via Developersdex http://www.developersdex.com ***
Aug 13 '08 #1
1 2014
Mike P wrote:
I am trying to return an output parameter to my code on executing a
stored procedure. In Query Analyzer, it works with no problem, but
when I run my ASP code below, the output parameter never seems to
return anything. Can anybody help?

Dim cmdNewCampaign, rsNewCampaign, intNumber
Const adCmdStoredProc = &H0004
Const adParamInput = &H0001
Const adParamOutput = &H0002
Const adVarChar = 200
Const adInteger = 3

Set cmdNewCampaign = Server.CreateOb ject ("ADODB.Command ")
cmdNewCampaign. ActiveConnectio n = strConnection
cmdNewCampaign. CommandText = "AddNewCampaign "
cmdNewCampaign. CommandType = adCmdStoredProc
cmdNewCampaign. Parameters.Appe nd
cmdNewCampaign. CreateParameter ("@CampaignName ",adVarChar,adP aramInput
,100, request("Campai gnName"))
cmdNewCampaign. Parameters.Appe nd
cmdNewCampaign. CreateParameter ("@CampaignID", adInteger,adPar amOutput)
Set rsNewCampaign = cmdNewCampaign. Execute

intNumber = cmdNewCampaign. Parameters("@Ca mpaignID")

1. SQL Server does not send return or output parameter values until all
resultsets generated by the stored procedure are consumed by the caller. It
appears, by your use of "Set rsNewCampaign = cmdNewCampaign. Execute" that
this procedure is intended to return a resultset. This means that you will
not see your output parameter value until you either close the recordset or
retrieve all the records being returned by the procedure (typically done by
navigating to the last record). I will typically use GetRows to pull all
the records into an array, allowing me to close the recordset and get my
output parameter values, but if you want to avoid using an array, and you
need to use the recordset data after retrieving the output value, you will
need to use a client-side cursor (set the recordset's cursorlocation
property to adUseClient).

2. Those informational "x rows were affected" messages that you see in Query
Analyzer are sent to the caller as resultsets. Those resultsets also need to
be consumed before output and return values are sent. You should make a
practice of suppressing those informational messages by including the line
"SET NOCOUNT ON" in every stored procedure that you write ... unless your
application needs those messages.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Aug 13 '08 #2

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

Similar topics

1
3982
by: Bari Allen | last post by:
I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First varchar(80) OUTPUT , @Second varchar(80) OUTPUT , @Third varchar(80) OUTPUT , @Amount as numeric(18,0) OUTPUT etc.
5
6041
by: vivienne.netherwood | last post by:
I am developing an Access Project front end with a SQL server database. I have written a stored procedure that returns a record set and also a value via an output parameter. The procedure is as follows CREATE PROCEDURE qslCheckShiftTimes @Ward NVARCHAR(6), @Shift NVARCHAR(10), @Exists TINYINT OUTPUT AS
4
1516
by: Janaka | last post by:
Hi this is kind of an ASP.NET/ADO.NET question. I've got a stored procedure on SQL Server that returns a results set. It also sets 3 output parameters in a seperate Select statement. When checking this on the database it returns all the results and output parameters. Now when I set up my SqlCommand objects parameters I specify 2 input and...
2
2536
by: Bari Allen | last post by:
ASP Classic question: I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First varchar(80) OUTPUT , @Second varchar(80) OUTPUT , @Third varchar(80) OUTPUT , @Amount as numeric(18,0) OUTPUT
3
4581
by: juststarter | last post by:
Hello all, I am executing a stored procedure (on an SQL Server) using ODBC but i can't get the output parameter's value on the client. The stored proc has 3 parameters ,2 of them are input and 1 is output. (for shake of simplicity let's suppose that the proc seems something like...
1
1796
by: Joe Van Meer | last post by:
Hi all, I have an app that currently runs through 3 seperate stored procedures each returning a count of records. What I would like to do is combine these calls into one call, however I am having an issue getting the output parameters' values after execution. Here is a snipit of code that calls one for simplicity's sake: I think I am...
1
8145
by: Garth Wells | last post by:
Using an example in the Jan 2006 release of the Enterprise Library, I came up with the code shown below to create a DAL method for returning several columns of a single row. I place the output parameter values in a comma-separated string, and then split the string to get the individual values on the calling page. This approach works, but I...
6
2714
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like this: ALTER proc getProductCommScale @product As varchar(30), @TISCommRate As Decimal(5,2) OUTPUT, @BrokerCommRate As Decimal(5,2) OUTPUT, @Fee As...
1
12296
by: John Bailo | last post by:
This is a my solution to getting an Output parameter from a SqlDataSource. I have seen a few scant articles but none of them take it all the way to a solution. Hopefully this will help some poor soul. Situation: I want to do a lookup using a stored procedure for each value in a Row within a GridView. I use a lookup function in my...
2
3366
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables @idUser int OUTPUT,
0
7695
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...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7964
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...
0
6281
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...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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...

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.