日期:2014-05-16 浏览次数:20973 次
public int GetDataTime(string name)
{
int dataValue = 0;
MySqlConnection myConnection = new MySqlConnection();
myConnection.ConnectionString = ContString;
try
{
myConnection.Open();
MySqlCommand myCommand = myConnection.CreateCommand();
if (name != null)
{
//根据warnime的最大值来取值
//myCommand.CommandText = "SELECT value FROM warnTable WHERE warntime=(SELECT MAX(warntime) FROM warnTable )";
myCommand.CommandText = "SELECT value FROM warnTable WHERE warntime=(SELECT MAX(warntime) FROM warnTable ) AND NAME ='" + name + "'";
//myCommand.CommandText = "Select Top 1 value Where name = '" + name + "' Order By warntime desc";
//myCommand.CommandText = "select top 1 * from warnTable where name='" + name + "' order by warntime desc";
//myCommand.CommandText = "SELECT value, MAX(warntime) FROM warnTable WHERE NAME = '" + name + "' group by value";
//myCommand.CommandText = "SELECT top 1 value FROM warnTable WHERE NAME = '" + name + "' ORDER BY warntime desc";
//判断是否查找成功
//DataSet myDataSet = new DataSet();
//MySqlDataAdapter myApter = new MySqlDataAdapter();