473,378 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Output parameters not returned from SP

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 3 output parameters. It
executes and returns a SqlDataReader which works fine. However when I go to
read the parameter values they are always null? Does anyone know why you
cannot get output parameters with a results set?

Thanks, J
Nov 18 '05 #1
4 1508
Hi,

did you close the DataReader before reading the parameters? You need to
close it first.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Janaka" <ja****@magicalia.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
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 3 output parameters. It executes and returns a SqlDataReader which works fine. However when I go to read the parameter values they are always null? Does anyone know why you
cannot get output parameters with a results set?

Thanks, J

Nov 18 '05 #2
"Janaka" <ja****@magicalia.com> wrote in
news:eJ**************@tk2msftngp13.phx.gbl:
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 3
output parameters. It executes and returns a SqlDataReader which
works fine. However when I go to read the parameter values they are
always null? Does anyone know why you cannot get output parameters
with a results set?


It is my understanding, that you cannot access the output parametres from a
stored procedure, if you return a datareader. You must return either
nothing or a dataset to access these properties.

(please correct me, if I am wrong)

Maybe you should try to post your question in
microsoft.public.dotnet.adonet

--
Jesper Stocholm http://stocholm.dk

Programmer's code comment:
//It probably makes more sense when you're stoned.
Nov 18 '05 #3
Thanks I didn't realise the reader's got to be closed first. Jesper, that
explains why creating a DataSet also works cause the connection is closed.
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

did you close the DataReader before reading the parameters? You need to
close it first.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Janaka" <ja****@magicalia.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
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 3 output parameters.

It
executes and returns a SqlDataReader which works fine. However when I go to
read the parameter values they are always null? Does anyone know why

you cannot get output parameters with a results set?

Thanks, J


Nov 18 '05 #4
"Janaka" <ja****@magicalia.com> wrote in
news:eB**************@TK2MSFTNGP12.phx.gbl:
Thanks I didn't realise the reader's got to be closed first. Jesper,
that explains why creating a DataSet also works cause the connection
is closed.


I got this from the SDK documentation on the SqlDataReader object

"..."
The Close method fills in the values for output parameters, return values
and RecordsAffected, increasing the amount of time it takes to close a
SqlDataReader that was used to process a large or complicated query.
"..."

:o)

--
Jesper Stocholm http://stocholm.dk

Programmer's code comment:
//It probably makes more sense when you're stoned.
Nov 18 '05 #5

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

Similar topics

1
by: PinkGuava | last post by:
Hi, I have a T-SQL stored procedure that returns both output parameters and a recordset. How do I retrieve them in my ASP script? As far as I know, the ADO Command object can be used to retrieve...
1
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 ,...
5
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...
2
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...
1
by: stjulian | last post by:
If inside a stored procedure, there a SELECT statement to return a recordset and another SELECT to set the value of an output parameter (as in SELECT @OutValue = Name FROM table WHERE pkid=5),...
1
by: Arpan | last post by:
A SQL Server 2005 DB table named "Users" has the following columns: ID - int (IDENTITY) FirstName - varchar(50) LastName - varchar(50) UserID - varchar(20) Password - varchar(20) Before...
6
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...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
8
by: Mike P | last post by:
How do you return a datareader from a stored procedure, but also return an output parameter? Here is my code, which is just returning a data reader at the moment : _conn.Open(); SqlCommand...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.