me_java9783 2014-06-10 08:18
浏览 659

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

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题