Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 out put parameter

Author  Topic 

BendJoe
Posting Yak Master

128 Posts

Posted - 2008-11-10 : 05:01:43
(
@Guid uniqueidentifier,
@UserID int,
@MediaBoxID int output

)
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRANSACTION
--Declare @MediaBoxID int;
Insert Into MediaBox (MediaBoxGUID,DateAdded,UserAdded) values (@Guid,getdate(),@UserID);
Set @MediaBoxID=Scope_Identity();
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error in Inserting into MediaBox.', 16, 1)
RETURN
END
Update ProfileInfo Set MediaBoxID=@MediaBoxID
where ProfileID=@UserID
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error in Updating ProfileInfo.', 16, 1)
RETURN
END
COMMIT
Select @MediaBoxID
END

I am trying to get an output parameter from the above procedure.
Below is the ADO.NET code

public static int AddMediaBoxGUIDByUserID(Guid guid, int userID, int mediaBoxID)
{
mediaBoxID = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, "usp_AddMediaBoxGUIDByUserID", guid, userID,mediaBoxID );
return mediaBoxID;
}
I am trying to get a return parameter for the first time. Some thing is going wrong. The procedure is getting executed as I can see the insert results. But the output parameter is not comming. Could someone help me.

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-10 : 05:06:32
possibly you r missing @parameter OUT while executing...

read out visakh replies
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=114111
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-10 : 05:11:25
you need to specify the output property in ADO.NET code as well

http://www.eggheadcafe.com/community/aspnet/10/10049998/u-get-output-parameter-va.aspx
Go to Top of Page
   

- Advertisement -