ExecuteNonQuery 简单sql语句
/// <summary>
/// 执行sql语句 ExecuteNonQuery
/// </summary>
/// <returns></returns>
public static int sql()
{
string conString = "data source=.;Database=Codematic;user id=sa;password=123";
SqlConnection myConnection = new SqlConnection(conString);
string strSql = "update P_Product set Name='电脑 1' where id=52";
myConnection.Open();
// SqlCommand myCommand = new SqlCommand(strSql, myConnection);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = strSql;
int row = myCommand.ExecuteNonQuery();
myConnection.Close();
return row;
}