[ACCEPTED]-How do I call a TSQL function from ado.net-ado.net

Accepted answer
Score: 29

The only difference is that you must have 2 a special paramter added for the return 1 value

See: MySqlCommand call function

  using (var connection = new SqlConnection("ConnectionString"))
  using (var command = connection.CreateCommand())
    command.CommandType = CommandType.StoredProcedure;
    command.CommandText = "MyFunction";

    SqlParameter returnValue = command.Parameters.Add("@RETURN_VALUE", SqlDbType.Int);
    returnValue.Direction = ParameterDirection.ReturnValue;


    return returnValue.Value;

More Related questions