public DbToWeb(string longservername) { InitializeComponent(); this.dbset = DbConfig.GetSetting(longservername); this.dbobj = DBOMaker.CreateDbObj(this.dbset.DbType); this.dbobj.DbConnectStr = this.dbset.ConnectStr; this.lblServer.Text = this.dbset.Server; }
public static IDbObject CreatDbObj(string longservername) { DbSettings setting = DbConfig.GetSetting(longservername); IDbObject dbObject = DBOMaker.CreateDbObj(setting.DbType); dbObject.DbConnectStr = setting.ConnectStr; return(dbObject); }
public static IDbScriptBuilder CreatDsb(string longservername) { DbSettings setting = DbConfig.GetSetting(longservername); IDbScriptBuilder dbScriptBuilder = DBOMaker.CreateScript(setting.DbType); dbScriptBuilder.DbConnectStr = setting.ConnectStr; return(dbScriptBuilder); }
//创建脚本接口 public static IDbScriptBuilder CreatDsb(string longservername) { DbSettings dbset = DbConfig.GetSetting(longservername); IDbScriptBuilder dsb = DBOMaker.CreateScript(dbset.DbType); dsb.DbConnectStr = dbset.ConnectStr; return(dsb); }
//创建数据库信息类接口 public static IDbObject CreatDbObj(string longservername) { DbSettings dbset = DbConfig.GetSetting(longservername); IDbObject dbobj = DBOMaker.CreateDbObj(dbset.DbType); dbobj.DbConnectStr = dbset.ConnectStr; return(dbobj); }
public SearchTables(MainForm mdiParentForm, string longservername) { InitializeComponent(); this.mainfrm = mdiParentForm; this.longServername = longservername; this.dbset = DbConfig.GetSetting(longservername); this.dbobj = DBOMaker.CreateDbObj(this.dbset.DbType); this.dbobj.DbConnectStr = this.dbset.ConnectStr; this.lblServer.Text = this.dbset.Server; this.CreatListView(); this.WorkLoad(); this.cmboxType.SelectedIndex = 0; }
public TemplateBatch(string longservername, bool isproc) { InitializeComponent(); this.dbset = DbConfig.GetSetting(longservername); this.dbobj = DBOMaker.CreateDbObj(this.dbset.DbType); this.dbobj.DbConnectStr = this.dbset.ConnectStr; this.lblServer.Text = this.dbset.Server; this.txtFolder.Text = this.dbset.Folder; this.isProc = isproc; if (this.isProc) { this.groupBox2.Text = "选择存储过程"; } }
private void btn_ConTest_Click(object sender, EventArgs e) { try { string text = this.comboBoxServer.Text.Trim(); string text2 = this.txtUser.Text.Trim(); string text3 = this.txtPass.Text.Trim(); if (text2 == "" || text == "") { MessageBox.Show(this, "服务器或用户名不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { if (this.GetSelVerified() == "Windows") { this.constr = "Integrated Security=SSPI;Data Source=" + text + ";Initial Catalog=master"; } else { if (text3 == "") { this.constr = "User Id=" + text2 + ";Database=master; Server=" + text; } else { this.constr = string.Concat(new string[] { "User Id=", text2, ";Password="******";Database=master; Server=", text }); } } string selVer = this.GetSelVer(); try { string sQLVer = this.GetSQLVer(this.constr); if (sQLVer != "11" && selVer == "SQL2012") { DialogResult dialogResult = MessageBox.Show(this, "该数据库服务器版本并非SQLServer 2012,是否进行重新选择?点“否”可继续。", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dialogResult == DialogResult.OK) { return; } } if (sQLVer != "10" && selVer == "SQL2008") { DialogResult dialogResult2 = MessageBox.Show(this, "该数据库服务器版本并非SQLServer 2008,是否进行重新选择?点“否”可继续。", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dialogResult2 == DialogResult.OK) { return; } } if (sQLVer != "9" && selVer == "SQL2005") { DialogResult dialogResult3 = MessageBox.Show(this, "该数据库服务器版本并非SQLServer 2005,是否进行重新选择?点“否”可继续。", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dialogResult3 == DialogResult.OK) { return; } } if (sQLVer != "8" && selVer == "SQL2000") { DialogResult dialogResult4 = MessageBox.Show(this, "该数据库服务器版本并非SQLServer 2000,是否进行重新选择?点“否”可继续。", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dialogResult4 == DialogResult.OK) { return; } } } catch { } try { this.Text = "正在连接服务器,请稍候..."; IDbObject dbObject = DBOMaker.CreateDbObj(selVer); if (dbObject == null) { LogInfo.WriteLog("创建数据库对象失败:" + selVer); MessageBox.Show(this, "创建数据库对象失败:" + selVer, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand); } else { dbObject.DbConnectStr = this.constr; List <string> dBList = dbObject.GetDBList(); dBList.Sort(); this.cmbDBlist.Enabled = true; this.cmbDBlist.Items.Clear(); this.cmbDBlist.Items.Add("全部库"); if (dBList != null && dBList.Count > 0) { foreach (string current in dBList) { this.cmbDBlist.Items.Add(current); } } this.cmbDBlist.SelectedIndex = 0; this.Text = "连接服务器成功!"; } } catch (Exception ex) { LogInfo.WriteLog(ex); this.Text = "连接服务器或获取数据信息失败!"; string text4 = "连接服务器或获取数据信息失败!\r\n"; text4 += "1.请检查服务器地址或用户名密码是否正确!\r\n"; text4 += "2.请确保是SQLServer正式版,而非SQLEXPRESS版!\r\n"; text4 += "3.如果连接失败,服务器名可以尝试用“机器名”代替IP,或者 “(local)”或是“.”试一下!\r\n"; text4 += "4.如果需要查看帮助文件以帮助您解决问题,请点“确定”,否则点“取消”"; DialogResult dialogResult5 = MessageBox.Show(this, text4, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand); if (dialogResult5 == DialogResult.OK) { try { new Process(); Process.Start("IExplore.exe", "http://help.maticsoft.com"); } catch { MessageBox.Show("请访问:http://www.maticsoft.com", "完成", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } } } catch (Exception ex2) { LogInfo.WriteLog(ex2); MessageBox.Show(this, ex2.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }