private void button1_Click_1(object sender, EventArgs e) { openFileDialog1.InitialDirectory = "d:\\bak"; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { textBox1.Text = openFileDialog1.FileName; this.core = new OledbCore(textBox1.Text); } if (!string.IsNullOrEmpty(textBox1.Text)) { if (comboBox1.SelectedValue.ToString() == "Oledb") { listBox1.DataSource = core.GetTables(""); } } }
/// <summary> /// 选择数据库类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void listBox2_SelectedIndexChanged(object sender, EventArgs e) { button1.Visible = comboBox1.SelectedValue.ToString() == "Oledb"; string v = comboBox1.SelectedValue.ToString(); if (v == "Oledb") { } else if (v == "MsSql") { // if (string.IsNullOrEmpty(textBox1.Text)) textBox1.Text = "server=192.168.104.117;uid=wftsa;password=jd7nTF#wM;database=K2Sln"; core = new MsSqlCore(textBox1.Text); } else if (v == "MySql") { // if (string.IsNullOrEmpty(textBox1.Text)) textBox1.Text = "Server=localhost;Uid=root;Pwd=niejunhua;"; core = new Coder.Core.MySqlCore(textBox1.Text); } }