I\'m trying to get output value from DB via ADO.NET. There\'s a client code:
using (var connection = new SqlConnection(ConnectionString))
{
you have to set Size for parameter output
using (var connection = new SqlConnection(ConnectionString))
{
connection.Open();
SqlCommand command = new SqlCommand("pDoSomethingParamsRes", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@i", 1);
var outParam = new SqlParameter("@out", SqlDbType.VarChar);
outParam.Direction = ParameterDirection.Output;
outParam.Size = 50; // this is example
command.Parameters.Add(outParam);
command.ExecuteNonQuery();
Console.WriteLine(command.Parameters["@out"].Value.ToString());
}