private void Btn_TestConnection_Click(object sender, EventArgs e) { Btn_TestConnection.Enabled = false; if (PingTest(TextBox_Server.Text)) { string msg = ""; SybaseQueryer queryer = new SybaseQueryer(TextBox_Server.Text, TextBox_Username.Text, TextBox_Password.Text); if (queryer.TestConnection(out msg)) { Lbl_TestResult.Text = "连接成功。"; Lbl_TestResult.ForeColor = Color.Green; } else { Lbl_TestResult.Text = "连接失败!" + msg; Lbl_TestResult.ForeColor = Color.Red; } } else { Lbl_TestResult.Text = "连接失败!"; Lbl_TestResult.ForeColor = Color.Red; } Btn_TestConnection.Enabled = true; }
private void Btn_Query_Click(object sender, EventArgs e) { listView1.Items.Clear(); listView1.Columns.Clear(); if (Panel_Home.Visible == false) { Btn_Home.PerformClick(); } try { sybaseQueryer = new SybaseQueryer(_hostName, _userName, _password, _port, _database, _charset); sybaseQueryer.Connect(); _dataTable = sybaseQueryer.Query(Util.EncodingString(TextBox_QueryString.Text, sybaseQueryer.Charset, Encoding.Default.HeaderName)); FillListView(); sybaseQueryer.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }