/// <summary> /// 测试数据库连接情况,通过查询platinfo中的PlatZhos字段 /// </summary> private void Wait() { SetSqllb("数据库连接测试中", Color.Red); Thread.Sleep(2000); try { // string n = Myadapter_p.ScalarTest("未启用").ToString(); // if (n != null) if (MysqlHepler.SqlOpen()) { SetSqllb("数据库测试通过", Color.Green); MysqlHepler.SqlClose(); } else { SetSqllb("数据库连接失败(1)", Color.Red); } } catch (Exception) { SetSqllb("数据库连接失败(2)", Color.Red); } Thread.Sleep(200); Setwait(false); }
private void Search_Load(object sender, EventArgs e) { if (!MysqlHepler.SqlOpen()) { MessageBox.Show("数据库连接失败!"); } string sql = "Select * From mygas_manufacture"; DataTable dt = MysqlHepler.SqlReturnDs(sql).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { CLB_changjia.Items.Add(dt.Rows[i]["ManufactureName"].ToString()); manufacture[dt.Rows[i]["id"].ToString()] = dt.Rows[i]["ManufactureName"].ToString(); } DGV_MeterInfo.Visible = true; DGV_result.Visible = false; DGV_MeterInfo.ClearSelection(); DGV_result.ClearSelection(); AutoSizeColumn(DGV_result); AutoSizeColumn(DGV_MeterInfo); }