473,378 Members | 1,577 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.

Reading both result set and output parameter of SP in .Net Framework......

I have a stored procedure which returns records and output
parameters(SQL2K). How to call this stored procedure using ADO.Net so that
I can use both results in my application. I have .Net Framework 1.1.
when I use ExecuteReader() of Command object I cannot read the output
parametrs of the stored procedure in code.
Please advice.
Hewit


Nov 19 '05 #1
3 2033
in sqlserver, the output parameter values are returned after all result
sets. with a sql datareader (a forward only reader), this means you have to
read though all the rows (and result sets - MoreResults), or close the
reader which does the same. after this step, you can read the output
parameters (be sure to declare direction to include output).

-- bruce (sqlwork.com)
"Hewit" <He********@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
| I have a stored procedure which returns records and output
| parameters(SQL2K). How to call this stored procedure using ADO.Net so
that
| I can use both results in my application. I have .Net Framework 1.1.
| when I use ExecuteReader() of Command object I cannot read the output
| parametrs of the stored procedure in code.
| Please advice.
| Hewit
|
|
|
|
Nov 19 '05 #2
Bruce,
Since I am not finding the close method for datareader, I used Dispose and
Clear methods. But no help.
Hewit
"bruce barker" <no***********@safeco.com> wrote in message
news:uH**************@TK2MSFTNGP15.phx.gbl...
in sqlserver, the output parameter values are returned after all result
sets. with a sql datareader (a forward only reader), this means you have to read though all the rows (and result sets - MoreResults), or close the
reader which does the same. after this step, you can read the output
parameters (be sure to declare direction to include output).

-- bruce (sqlwork.com)
"Hewit" <He********@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
| I have a stored procedure which returns records and output
| parameters(SQL2K). How to call this stored procedure using ADO.Net so
that
| I can use both results in my application. I have .Net Framework 1.1.
| when I use ExecuteReader() of Command object I cannot read the output
| parametrs of the stored procedure in code.
| Please advice.
| Hewit
|
|
|
|

Nov 19 '05 #3
"Hewit" <He********@hotmail.com> confessed in news:e2#bUdc$EHA.2788
@TK2MSFTNGP15.phx.gbl:
Bruce,
Since I am not finding the close method for datareader, I used Dispose and Clear methods. But no help.
Hewit
"bruce barker" <no***********@safeco.com> wrote in message
news:uH**************@TK2MSFTNGP15.phx.gbl...
in sqlserver, the output parameter values are returned after all result
sets. with a sql datareader (a forward only reader), this means you have

to
read though all the rows (and result sets - MoreResults), or close the
reader which does the same. after this step, you can read the output
parameters (be sure to declare direction to include output).

-- bruce (sqlwork.com)
"Hewit" <He********@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP09.phx.gbl...
| I have a stored procedure which returns records and output
| parameters(SQL2K). How to call this stored procedure using ADO.Net so
that
| I can use both results in my application. I have .Net Framework 1.1.
| when I use ExecuteReader() of Command object I cannot read the output
| parametrs of the stored procedure in code.
| Please advice.
| Hewit
|
|
|
|



First, assume you've created appropriate parameter associated with the
command:

SqlParameter pReturn = new System.Data.SqlClient.SqlParameter
("@RETURN_VALUE", System.Data.SqlDbType.Int,
System.Data.ParameterDirection.ReturnValue, false, ... );

myCommand.Parameters.Add(pReturn);

...

Then call the command creating the reader and set it up to close the
connection:

myConnection.Open();
SqlDataReader rdr = myCommand.ExecuteReader
(CommandBehavior.CloseConnection);

Then when finished with the reader, close. It will close the associated
connection:

rdr.Close();

Then the return value parameter of the SPROC are made available by
ADO.NET

int myInt = (int)pReturn.Value;
Give it a try. But I am surprised you couldn't find a Close() method for
the SqlDataReader class?

-- ipgrunt

Nov 19 '05 #4

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

Similar topics

7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
9
by: EkteGjetost | last post by:
I would like to first apologize to those of you who read my last post "desperately need help". As a regular on other forums i can understand how aggravating it would be to have someone come on who...
8
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY...
3
by: tshad | last post by:
I am trying to set up a class to handle my database accesses. I can't seem to figure out how to get the return value from my dataReader from these routines (most of which I got elsewhere). They...
7
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) ...
11
by: downwitch | last post by:
Hi, I'm using a 3rd-party app's back end which stores SQL statements in a table, so I have no choice but to use dynamic SQL to call them (unless someone else knows a workaround...) Problem...
0
by: pbaillard | last post by:
Here a sample to call a stored procedure with an Oracle Database. odc.Connection = m_cDb ' use an open connection to your database odc.CommandType = CommandType.StoredProcedure odc.CommandText =...
7
by: sonet | last post by:
in perl we can execute command and get result(command line stdout) by $a=`cmdline parameter`; print $a; in c system('cmdline parameter'); but i can not get the result (command line stdout).
1
by: Manners | last post by:
Hi! I am a VBA newbie, and cant seem to proceed past my current problem. I have a large query, where I need to output a select query based on the parameter set by the do loop. The do loop is...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.