Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Easy one
Message
 
To
07/11/2002 12:09:11
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
General information
Forum:
ASP.NET
Category:
Databases
Title:
Miscellaneous
Thread ID:
00719894
Message ID:
00719919
Views:
14
Jim.

You need to alter you procedure to the following to allow for output parameters.
ALTER PROCEDURE dbo.GetMaxTaskNo
(
	@project_id int,
        @RETURN_VALUE int OUTPUT
)
AS
SELECT @RETURN_VALUE=max(isNull(task_no,0)) AS "MaxTaskNo"
	FROM task_header
	WHERE project_id = @project_id

	RETURN
Then in .NET you call the stored procedure like the following:
SqlCommand cmd = new SqlCommand("GetMaxTaskNo",conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add["@project_id",SqlDbType.Int,8];
cmd.Parameters.Add["@RETURN_VALUE",SqlDbType.Int,8];
cmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
Console.WriteLine(cmd.Parameters["@RETURN_VALUE"].Value);
>All
>
>I'm working on a webform that populates a textbox by using the max() function from a stored procedure. I need the store procedure to return a value to the @RETURN_VALUE parameter in my dataadapter. How do I do this? The code for the stored procedure is below.
>
>
>ALTER PROCEDURE dbo.GetMaxTaskNo
>(
>	@project_id int
>)
>AS
>SELECT max(isNull(task_no,0)) AS "MaxTaskNo"
>	FROM task_header
>	WHERE project_id = @project_id
>
>	RETURN
>
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform