1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
using (SqlConnection connection = newSqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "sp_testInputOutput";
command.CommandType = System.Data.CommandType.StoredProcedure;
// param entr‚e
command.Parameters.AddWithValue("@input1", "test");
// params en sortie
SqlParameter paramOutput1 = command.Parameters.Add("@output1", System.Data.SqlDbType.VarChar, 100);
paramOutput1.Direction = System.Data.ParameterDirection.Output;
SqlParameter paramOutput2 = command.Parameters.Add("@output2", System.Data.SqlDbType.VarChar, 100);
paramOutput2.Direction = System.Data.ParameterDirection.Output;
// run ps
command.ExecuteNonQuery();
// display test result
Console.WriteLine(paramOutput1.Value);
Console.WriteLine(paramOutput2.Value);
}
connection.Close();
}
|
Partager