【C#】 “万能”函数
public static DataTable SelectSqlReturnTable(string sql, CommandType type, SqlParameter[] pars) { SqlConnection con = new SqlConnection(ConnString); SqlDataAdapter sda = new SqlDataAdapter(sql, con); sda.SelectCommand.CommandType = type; if (pars != null && pars.Length > 0) { foreach (SqlParameter p in pars) { sda.SelectCommand.Parameters.Add(p); } } DataTable dt = new DataTable(); sda.Fill(dt); return dt; }