privatevoidcount(objectsender,EventArgse){stringstr1="select*from表名where条件"
;//读取整张表MySqlConnectioncoon=MySQL.getMySqlCon()
;//连接数据库,调方法MySqlCommandmySqlCommand1=MySQL.getSqlCommand(str1,coon);coon.Open();intrecord1=MySQL.getResultCount(mySqlCommand1);coon.Close();label1.Text=record1.ToString();
}//建立执行命令的语句对象publicstaticMySqlCommandgetSqlCommand(Stringsql,MySqlConnectionmysql){MySqlCommandmySqlCommand=newMySqlCommand(sql,mysql);returnmySqlCommand;}//查询记录数publicstaticintgetResultCount(MySqlCommandmySqlCommand){MySqlDataReaderreader=mySqlCommand.ExecuteReader();intresult=0;try{while(reader.Read()){if(reader.HasRows){result=result+1;}}}catch(Exception){}finally{reader.Close();}returnresult;
}//此方法连接数据库publicstaticMySqlConnectiongetMySqlCon(){StringmysqlStr="Database=test3;DataSource=127.0.0.1;UserId=root;Password=123456;pooling=false;CharSet=utf8;port=3306;AllowZeroDatetime=True";MySqlConnectionmysql=newMySqlConnection(mysqlStr)
;returnmysql;}
如何申请域名邮箱,怎么在自媒体上打广告语,win7怎么设置最佳性能如何申请域名邮箱,怎么在自媒体上打广告语,win7怎么设置最佳性能