取得 Stored Procedures 內的參數
using (SqlConnection conn = new SqlConnection("ConnectionString"))
{
SqlCommand cmd = new SqlCommand("SPName", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlCommandBuilder.DeriveParameters(cmd);
foreach (SqlParameter parameter in cmd.Parameters)
{
if (parameter.Direction == ParameterDirection.Input || parameter.Direction == ParameterDirection.InputOutput)
{
Console.WriteLine(parameter.ParameterName);
}
}
}
就這樣…