Skip to content Skip to sidebar Skip to footer

Sql Output Parameters In C#

I'm trying to get a value from Microsoft SQL Server stored procedure. Totally I need to return two values. As you see below one of them is accessible by return and the other is acc

Solution 1:

Seems like you forget the @ prefix for your sql parameter :

logID = (int)command.Parameters["@logID"].Value;

Solution 2:

May be that your logID = (int)command.Parameters["logID"].Value; does not access the logId because it should be named @logID, as you've added it like:

command.Parameters.Add("@logID", SqlDbType.Int).Value = 0;
command.Parameters["@logID"].Direction = ParameterDirection.Output; 

and '@' must be part of the parameter name - Is it necessary to add a @ in front of an SqlParameter name?

Solution 3:

@ is missing, update like the following

logID = (int)command.Parameters["@logID"].Value;

Post a Comment for "Sql Output Parameters In C#"