mysql模拟查询in,如何建立查询消费账单

更新时间:01-23 教程 由 凉月 分享
mysql模拟查询in,如何建立查询消费账单?

//获得数据写入text(主方法)

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;}

声明:关于《mysql模拟查询in,如何建立查询消费账单》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2209394.html