473,385 Members | 1,548 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,385 software developers and data experts.

how to get an OutPut parameter value of a stored procedure?

Hi there,

I would like to call a stored procedure with an OutPut parameter and then
get the value of the OutPut in C#, here is my code, I expect it displays 1
for @MyOutPutInt but nothing actually displayed.
....
CDatabase oDatabase = new CDatabase(sConnectionString);
try
{
oDatabase.Open();
CParameterCollection colParameters = new CParameterCollection();
colParameters.AddOutputParameterInt("@MyOutPutInt" );
oDatabase.ExecuteSP("sp_MySP", colParameters);
Console.WriteLine("@MyOutPutInt = {0}",
colParameters["@MyOutPutInt"].value);
}
catch
{
Console.WriteLine("something wrong!");
}
finally
{
oDatabase.Close();
}

the sp_MySP is something like below:

create sp_MySP
@MyOutPutInt int output
as
set @MyOutPutInt = 1
return
go

Thanks!
Nov 17 '05 #1
0 1047

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

Similar topics

5
by: Steve Holden | last post by:
Has anyone, with any driver whatsoever, managed to retrieve output parameters from a SQL Server stored procedure? I've just been rather embarrassed to find out it's not as easy as it might seem,...
4
by: Steven | last post by:
I'm calling a stored procedure which has an output parameter of type int. Once the stored procedure is executed, I want to check the value of the parameter in case it is null. However, when the a...
4
by: laurenq uantrell | last post by:
I need to get the value of an output parameter back into my VBA function calling a stored procedure. I'm using the following construction to append a new record in a SQL Server table: ...
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...
8
by: Christopher Weaver | last post by:
I'm having trouble accessing the value of an output parameter of a stored procedure. The SP looks like this: SET TERM ^ ; CREATE PROCEDURE SP_NEW_TASK RETURNS ( "uidTask" INTEGER) AS begin
4
by: Mr Not So Know It All | last post by:
im new to SQL Server and ASP.Net. Here's my problem. I have this SQL Server stored procedure with an input parameter and output parameter CREATE PROCEDURE . @in_rc varchar(8) @out_eList...
4
by: Tifer | last post by:
Hello, I'm still new to the whole .Net thing and I'm having a problem with something that should be so simple -- executing a query and returning an output parameter. It's a standard "Add"...
4
by: Clint Pidlubny | last post by:
Hello, I'm using ASP.Net 2.0 and the Jan 2006 Enterprise Library. What I'm doing is passing an ArrayList into a stroed procedure to do an Insert. Here's some code: Dim params as New...
7
by: ashtek | last post by:
Hi, I have a generic function that executes a stored procedure & returns a data table. Code: === public static DataTable ExecuteStoredProcedure(string strProc,SqlParameter paramArray) {...
1
by: Mike P | last post by:
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...
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
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: 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: 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...
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: 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.