November 12, 2007 at 10:18 am
It should be noted that the “@” symbol is a syntax flag for parameters in the SQL CommandString, and is not part of the actual Parameter Name. The .Add methods will accept the name with or without the “@” symbol for convenience, but it’s not technically proper to include it since it isn’t really part of the name.
December 5, 2007 at 3:35 am
Hi,
I'm new to ASP.NET and ADO.NET and was just trying out SqlParameter. How do I use SqlParameter to get a return code along with other parameters (input). I have a stored procedure that accepts some parameters to insert new record in a table.
I need to get the return code whether my insert execution is successful or not. So how do I get the return code?
Thanks in a million.
December 5, 2007 at 8:10 am
Halim Dahlan (12/5/2007)
Hi,I'm new to ASP.NET and ADO.NET and was just trying out SqlParameter. How do I use SqlParameter to get a return code along with other parameters (input). I have a stored procedure that accepts some parameters to insert new record in a table.
I need to get the return code whether my insert execution is successful or not. So how do I get the return code?
Thanks in a million.
Sorry I don't usually use myself but as I recall if you have a return code the parameter collection of the SqlCommand object will contain it in the 0 item or @ret item so something like this in C# (assuming your SqlCommand object is named cmdSQL)
cmdSQL.Parameters[0]...
or
cmdSQL.Parameters["@ret"]...
December 5, 2007 at 4:14 pm
Try the following code, it should get you started:
SqlCommand cmd = new SqlCommand("usp_Table_Action");
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@ReturnCode", SqlDbType.Int);
param.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(param);
December 5, 2007 at 8:52 pm
Hey thanks a lot programmer. It worked.
Viewing 5 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply