Public static DataTable Query (SQL, string params SqlParameter [] cmdParms)
{
SqlDataAdapter sda=new SqlDataAdapter ();
SqlCommand com=new SqlCommand (SQL, Conn);
Foreach (SqlParameter param in cmdParms)
{
Com. The Parameters. The Add (param);
}
Sda. SelectCommand=com;
The DataTable dt=new DataTable ();
Sda. The Fill (dt);
Return dt.
}
Among them, the params SqlParameter [] cmdParms reference parameters of such a method should be how to create before calling this method? Specific grammar should be how to write? Add the SqlParameter to a SqlParameter [] array?
CodePudding user response:
Params said variable parameter, you can use array, also can be individual parameters of the same type, use commas,