Can some one offer me some assistance?
I'm using a SQLDataSource control to call a stored proc to insert a record into a control. The stored proc I'm calling has an output paramater that returns the new rows identity field to be used later. I'm having trouble getting to this return value via the SQLDataSource . Below is my code (C#):
SqlDataSource1.InsertParameters["USR_AUTH_NAME"].DefaultValue = storeNumber;
SqlDataSource1.InsertParameters["usr_auth_pwd"].DefaultValue =string.Empty;
SqlDataSource1.InsertParameters["mod_usr_name"].DefaultValue ="SYSTEM";
SqlDataSource1.InsertParameters["usr_auth_id"].Direction =ParameterDirection.ReturnValue;
SqlDataSource1.Insert();
int id =int.Parse(SqlDataSource1.InsertParameters["usr_auth_id"].DefaultValue);
below is the error I'm getting:
System.Data.SqlClient.SqlException: Procedure 'csi_USR_AUTH' expects parameter '@.usr_auth_id', which was not supplied.
Has anyone done this before and if so how did you do it?
How did you define the stored procedure 'csi_USR_AUTH' ? Since you add the Direction of usr_auth_id toParameterDirection.ReturnValue, you don't need to declare a @.usr_auth_id parameter in the sp; instead, it will be filled by using a RETURN command. Check this article to see how to use ReturnValue parameter:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconinputoutputparametersreturnvalues.asp
No comments:
Post a Comment