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#程序了,也没报错,不好找问题啊!