public SqlCommand CreateProcedureCmd(string procName, params string[] prams)
{
if ( conn.State==ConnectionState.Closed)
conn.Open();
SqlCommand Cmd = new SqlCommand(procName, conn);
Cmd.CommandType = CommandType.StoredProcedure;
if (prams != null)
{
foreach (string parameter in prams)
{
if(parameter != null)
{
Cmd.Parameters.Add(parameter);
}
}
}
return Cmd;
}
此时parmas参数可以按顺序填写参数或者直接添加数组。