public DbToScript(string longservername, string dbname) { InitializeComponent(); DbName = dbname; dsb = ObjHelper.CreatDsb(longservername); dbobj = ObjHelper.CreatDbObj(longservername); this.lblServer.Text = longservername; List <string> dblist = dbobj.GetDBList(); if (dblist != null) { if (dblist.Count > 0) { foreach (string name in dblist) { this.cmbDB.Items.Add(name); } } } //DataTable dt = dbobj.GetDBList(); //if (dt != null) //{ // foreach (DataRow row in dt.Rows) // { // this.cmbDB.Items.Add(row["name"].ToString()); // } //} this.btn_Creat.Enabled = false; this.cmbDB.Text = DbName; }
private void DbToWord_Load(object sender, System.EventArgs e) { string mastedb = "master"; switch (dbobj.DbType) { case "SQL2000": case "SQL2005": mastedb = "master"; break; case "Oracle": case "OleDb": mastedb = dbset.DbName; break; case "MySQL": mastedb = "mysql"; break; } if ((dbset.DbName == "") || (dbset.DbName == mastedb)) { List <string> dblist = dbobj.GetDBList(); if (dblist != null) { if (dblist.Count > 0) { foreach (string dbname in dblist) { this.cmbDB.Items.Add(dbname); } } } } else { this.cmbDB.Items.Add(DbName); } this.btn_Creat.Enabled = false; this.cmbDB.Text = DbName; }
public DbToScript(string longservername) { InitializeComponent(); dsb = ObjHelper.CreatDsb(longservername); dbobj = ObjHelper.CreatDbObj(longservername); int s = longservername.IndexOf("("); string server = longservername.Substring(0, s); this.lblServer.Text = server; List <string> dblist = dbobj.GetDBList(); if (dblist != null) { if (dblist.Count > 0) { foreach (string dbname in dblist) { this.cmbDB.Items.Add(dbname); } } } //DataTable dt = dbobj.GetDBList(); //if (dt != null) //{ // foreach (DataRow row in dt.Rows) // { // string dbname = row["name"].ToString(); // this.cmbDB.Items.Add(dbname); // } //} this.btn_Creat.Enabled = false; if (cmbDB.Items.Count > 0) { this.cmbDB.SelectedIndex = 0; } }
private void btn_ConTest_Click(object sender, EventArgs e) { try { string server = this.comboBoxServer.Text.Trim(); string user = this.txtUser.Text.Trim(); string pass = this.txtPass.Text.Trim(); string port = this.textBox1.Text.Trim(); if ((user == "") || (server == "")) { MessageBox.Show(this, "服务器或用户名不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { constr = String.Format("server={0};uid={1}; Port={2};pwd={3}; pooling=false", server, user, port, pass); try { this.Text = "正在连接服务器,请稍候..."; Maticsoft.IDBO.IDbObject dbobj = Maticsoft.DBFactory.DBOMaker.CreateDbObj("MySQL"); dbobj.DbConnectStr = constr; List <string> dblist = dbobj.GetDBList(); this.cmbDBlist.Enabled = true; this.cmbDBlist.Items.Clear(); this.cmbDBlist.Items.Add("全部库");//5_1_a_s_p_x if (dblist != null && dblist.Count > 0) { foreach (string dbname in dblist) { this.cmbDBlist.Items.Add(dbname); } } this.cmbDBlist.SelectedIndex = 0; this.Text = "连接服务器成功!"; } catch (System.Exception ex) { LogInfo.WriteLog(ex); this.Text = "连接服务器或获取数据信息失败!"; DialogResult drs = MessageBox.Show(this, "连接服务器或获取数据信息失败!\r\n请检查服务器地址或用户名密码是否正确!查看帮助文件以帮助您解决问题?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand); //if (drs == DialogResult.OK) //{ // try // { // //Process proc = new Process(); // //Process.Start("IExplore.exe", "http://help.maticsoft.com"); // } // catch // { // MessageBox.Show("请访问:http://www.maticsoft.com", "完成", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); // } //} //return; } } } catch (Exception ex2) { LogInfo.WriteLog(ex2); MessageBox.Show(this, ex2.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }