SqlConnection conn = new SqlConnection(DefaultConnection);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType = CommandType.StoredProcedure;
// 参数
if (Parameters != null && Parameters.Count > 0)
{
// 判断存储过程含不含该参数
SqlCommandBuilder.DeriveParameters(cmd);
for (int i = 0; i < Parameters.Count; i++)
{
string Key = "@" + Parameters[i].name;
if (cmd.Parameters.Contains(Key))
{
cmd.Parameters[Key].Value = Parameters[i].value;
}
}
}
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
return ds;