日期:2014-05-17 浏览次数:21030 次
namespace 脱机监控
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
IDataReader dr;
Thread t;
private void Form1_Load(object sender, EventArgs e)
{
genlist();
Thread t = new Thread(checknetwork);
t.IsBackground = true;
t.Start();
}
public void genlist()
{
//清空lsv,防止重复生成列表
listView1.Clear();
dr = null;
//加载数据库中的监控点到ListView
using (MySqlConnection conn = new MySqlConnection(sqlconnstr))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand("select * from checkpoint", conn))
{
dr = cmd.ExecuteReader();
//遍历记录集,将监控点信息添加到ListView中,checkpointname标记监控点,checkpointip为IP地址
while (dr.Read())
{
ListViewItem Item = new ListViewItem(dr["checkpointname"].ToString(), 0);
Item.ToolTipText = dr["checkpointip"].T