大家好,下面是一个数据库查询过程,用定时器控制进入,可是为什么这个过程只能进入一次,第二次就死在里面出不来了呢.想不通呀.
string PubConnstr,Pathstr,Sqlstr;
Timer1.eanble= false ;关闭定时器,以免没有执行完再次进入过程
Txt_Info.Text = "进入过程";
Txt_Info.Refresh();
timer1.Enabled = false;
QueryCount = QueryCount + 1;
OdbcConnection OdbcConn = new OdbcConnection() ;
OdbcDataAdapter OdbcData = new OdbcDataAdapter();
OdbcCommand OdbcComm = new OdbcCommand();
DataSet TmpDs = new DataSet();
Pathstr = Application.StartupPath ;
PubConnstr = "provider=MSDASQL.1;user id=admin;password=;driver=microsoft visual foxpro driver;sourcedb="+Pathstr+";sourcetype=dbf;Persist Security Info=False;
OdbcConn.ConnectionString = PubConnstr;
OdbcConn.Open();
Txt_Info.Text = "打开数据库正常...";
Txt_Info.Refresh();
Sqlstr = "Select * From Piaolst where days > {^2006-10-10}";
OdbcComm.CommandText = Sqlstr;
OdbcComm.Connection = OdbcConn;
OdbcComm.ExecuteNonQuery();
Txt_Info.Text = "查询数据库正常...";
Txt_Info.Refresh();
OdbcData.SelectCommand = OdbcComm;
OdbcData.Fill(TmpDs,"Piaolst");
textBox1.Text = TmpDs.Tables[0].Rows.Count.ToString();
timer1.Enabled = true;
Txt_Info.Text = "查询次数:"+ QueryCount.ToString();
Txt_Info.Refresh();
timer1.eanble = true ;//再次打开定时器,让程序重新进入这个过程,
实际上,第二次还是进入了,但提示信息在查询数据库正常这里就死掉了,看样子是在FILL这里出错了.有没有办法呀..
[此贴子已经被作者于2006-10-25 17:31:31编辑过]