2 me java9783 me_java9783 于 2014.06.10 16:18 提问

C#循坏不运行,不循坏就可以运行

while(true)
{
Thread.Sleep(5000);
SqlConnection conn = new SqlConnection("server=.\sqlexpress;database=ERP;user id=sa;pwd=config;");
SqlCommand cmd = new SqlCommand("select top 1 * from ERPGongGao order by id desc", conn);
SqlCommand cmd1 = new SqlCommand("select top 1 * from ERPTelFile order by id desc", conn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
sda.Fill(ds);
sda1.Fill(ds1);
conn.Open();
string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
string timeStr = ds.Tables[0].Rows[0]["timeStr"].ToString().Substring(0, 16);
string timeStr1 = ds1.Tables[0].Rows[0]["timeStr"].ToString().Substring(0, 16);
string text = ds.Tables[0].Rows[0]["TitleStr"].ToString();
string text1 = ds1.Tables[0].Rows[0]["TitleStr"].ToString();
if (true)//(nowTime == timeStr)
{
string name = "公告:";
shouwindow(name, text);
//MessageBox.Show("办公平台提醒已经开启!有新消息会提醒。"+i);
}
else if (nowTime == timeStr1)
{
string name1 = "文件:";
shouwindow(name1, text1);
//MessageBox.Show("办公平台提醒已经开启!有新消息会提醒。");
}
conn.Close();
}

桌面小程序,不循坏就可以运行,循坏就不运行了.很久没做过C#程序了,也没报错,不好找问题啊!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!