public int ExecuteNonQuery (string connstring, CommandType cmdtype, String cmdtext, params sqlparameter[] cmdparms)
{
SqlCommand cmd = new SqlCommand ();
using (SqlConnection conn = new SqlConnection (connstring))
{
PrepareCommand (CMD, conn, null, Cmdtype, Cmdtext, cmdparms);
int val = cmd. ExecuteNonQuery ();
Cmd. Parameters.clear ();
return Val;
}
}
<summary>
Executes an SQL Command (using implied connectstring)
</summary>
<param name= "Cmdtype" >command type </param>
<param name= "Cmdtext" >command statement (SQL statement) </param>
<param name= "cmdparms" >command parameter (sqlparameter[) array type) </param>
<returns>command return value (number of rows affected) </returns>
public int ExecuteNonQuery (CommandType cmdtype, String cmdtext, params sqlparameter[] cmdparms)
{
SqlCommand cmd = new SqlCommand ();
using (SqlConnection conn = new SqlConnection (Constr))
{
PrepareCommand (CMD, conn, null, Cmdtype, Cmdtext, cmdparms);
int val = cmd. ExecuteNonQuery ();
Cmd. Parameters.clear ();
return Val;
}
}
public static int ExecuteNonQuery (string cmdtext)
// {
// }
<summary>
Execute a simple query, just enter the SQL statement, typically used to update or delete
</summary>
<param name= "SQLText" ></param>
<returns></returns>
public int ExecuteNonQuery (string sqltext)
{
Return ExecuteNonQuery (Commandtype.text,sqltext);
}
<summary>
Executes an SQL Command (using sqltransaction)
</summary>
<param name= "Trans" > Use of sqltransaction</param>
<param name= "Cmdtype" >command type </param>
<param name= "Cmdtext" >command statement (SQL statement) </param>
<param name= "cmdparms" >command parameter (sqlparameter[) array type) </param>
<returns>command return value (number of rows affected) </returns>
public int ExecuteNonQuery (SqlTransaction trans, CommandType cmdtype,string Cmdtext, params sqlparameter[] cmdparms)
{
SqlCommand cmd = new SqlCommand ();
PrepareCommand (cmd, trans.) Connection, trans, Cmdtype, Cmdtext, cmdparms);
int val = cmd. ExecuteNonQuery ();
Cmd. Parameters.clear ();
return Val;
}
<summary>
Automatically generates CMD to perform the update of the dataset according to the specified dscommandtype type
</summary>
<param name= "connstring" >connectstring (SQL connection string) </param>
<param name= "Cmdtype" >command type </param>
<param name= "Dscommandtype" >enum type </param>
<param name= "Cmdtext" >command statement (SQL statement) </param>
<param name= "DataSet" >dataset</param>
<param name= "tablename" > table name </param>
<param name= "cmdparms" >command parameter (sqlparameter[) array type) </param>
<returns> Update Success </returns>
public bool ExecuteNonQuery (string Connstring,commandtype cmdtype,commandenum.dscommandtype dscommandtype,string Cmdtext,dataset dataset,string tablename,params sqlparameter[] cmdparms)
{
SqlDataAdapter dscommand = new SqlDataAdapter ();
SqlCommand cmd = new SqlCommand ();
using (SqlConnection conn = new SqlConnection (connstring))
{
IF (Conn. State!= ConnectionState.Open)
Conn. Open ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.