private void button2_Click(object sender, EventArgs e) { FT.DAL.Access.AccessDataHelper access = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=\\\\" + this.txtShareDbIp.Text.Trim() + "\\db\\db.mdb;Jet OLEDB:Database Password=SQL"); try { if (access.Open()) { XmlDocument doc = new XmlDocument(); doc.Load(Application.ExecutablePath + ".config"); XmlNode node1 = doc.SelectSingleNode(@"//add[@key='" + connKey + "']"); XmlElement ele1 = (XmlElement)node1; ele1.SetAttribute("value", FT.Commons.Security.SecurityFactory.GetSecurity().Encrypt("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=\\\\" + this.txtShareDbIp.Text.Trim() + "\\db\\db.mdb;Jet OLEDB:Database Password=SQL")); doc.Save(Application.ExecutablePath + ".config"); MessageBoxHelper.Show("保存成功,请退出重进!"); access.Close(); } else { MessageBox.Show("连接" + this.txtShareDbIp.Text.Trim() + "失败,请检查目标机器是否可用,\r\n是否已经共享预录入系统的db文件夹!", "提示"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected override void OnLoad(EventArgs e) { if (!IsPostBack) { string sql = "insert into Access_Record(computer_name,computer_ip,access_url,access_time) values('{0}','{1}','{2}','{3}')"; FT.DAL.Access.AccessDataHelper access = new FT.DAL.Access.AccessDataHelper(Server.MapPath("~/db/db.mdb"), "admin", ""); IPHostEntry hostInfo = Dns.GetHostByAddress(Request.UserHostAddress); access.ExecuteSql(string.Format(sql, hostInfo.HostName, Request.UserHostAddress.ToString(), Request.Url, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); } }
private void button1_Click(object sender, EventArgs e) { string ip = this.txtIp.Text.Trim(); string dbname = this.txtDbName.Text.Trim(); string userid = this.txtUID.Text.Trim(); string pwd = this.txtPwd.Text.Trim(); if (dbname.Length > 0 && userid.Length > 0) { FT.DAL.IDataAccess access = null; if (this.cbDbType.Text.Trim().ToLower() == "sqlserver") { access = new FT.DAL.SqlServer.SqlServerDataHelper(ip, dbname, userid, pwd); } else if (this.cbDbType.Text.Trim().ToLower() == "oracle") { access = new FT.DAL.Oracle.OracleDataHelper(dbname, userid, pwd); } else if (this.cbDbType.Text.Trim().ToLower() == "access") { if (pwd.Length > 0) { access = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=" + dbname + ";Jet OLEDB:Database Password="******"测试成功!", "提示"); access.Close(); } else { MessageBox.Show("测试失败!", "提示"); } } catch (Exception ex) { MessageBoxHelper.Show(ex.ToString()); } } else { MessageBoxHelper.Show("必须填写数据库名和登陆名"); } }
private void CreatePlugin() { if (firstPlugin) { string path = Application.StartupPath + "/plugins/SystemPlugin.dll"; FileInfo dir = new FileInfo(path); AllPrinterConfig config = AllPrinterConfig.GetPrinterConfig(); string ip = config.SysConfig.Ip; string dbname = config.SysConfig.DbName; string userid = config.SysConfig.UID; string pwd = config.SysConfig.Pwd; if (dir.Exists && dbname.Length > 0 && userid.Length > 0) { System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFile(path); Type t = ass.GetType("SystemPlugin.StudentPlugin"); Type t1 = typeof(FT.DAL.IDataAccess); System.Reflection.ConstructorInfo cinfo = t.GetConstructor(new Type[] { t1 }); object o1 = null; if (config.SysConfig.DbType.ToLower() == "sqlserver") { o1 = new FT.DAL.SqlServer.SqlServerDataHelper(ip, dbname, userid, pwd); } else if (config.SysConfig.DbType.ToLower() == "oracle") { o1 = new FT.DAL.Oracle.OracleDataHelper(dbname, userid, pwd); } else if (config.SysConfig.DbType.ToLower() == "access") { if (pwd.Length > 0) { o1 = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=" + dbname + ";Jet OLEDB:Database Password="******"没有找到插件类,无法同步!"); } } firstPlugin = false; } }
private void btnTestShareDb_Click(object sender, EventArgs e) { FT.DAL.Access.AccessDataHelper access = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=\\\\" + this.txtShareDbIp.Text.Trim() + "\\db\\db.mdb;Jet OLEDB:Database Password=SQL"); try { if (access.Open()) { MessageBox.Show("连接成功!", "提示"); access.Close(); } else { MessageBox.Show("连接" + this.txtShareDbIp.Text.Trim() + "失败,请检查目标机器是否可用,\r\n是否已经共享预录入系统的db文件夹!", "提示"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void CreatePlugin() { if (firstPlugin) { string path = Application.StartupPath + "/plugins/SystemPlugin.dll"; FileInfo dir = new FileInfo(path); AllPrinterConfig config = AllPrinterConfig.GetPrinterConfig(); string ip = config.SysConfig.Ip; string dbname = config.SysConfig.DbName; string userid = config.SysConfig.UID; string pwd = config.SysConfig.Pwd; if (dir.Exists && dbname.Length > 0 && userid.Length > 0) { System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFile(path); Type t = ass.GetType("SystemPlugin.StudentPlugin"); Type t1 = typeof(FT.DAL.IDataAccess); System.Reflection.ConstructorInfo cinfo = t.GetConstructor(new Type[] { t1 }); object o1 = null; if (config.SysConfig.DbType.ToLower() == "sqlserver") { o1 = new FT.DAL.SqlServer.SqlServerDataHelper(ip, dbname, userid, pwd); } else if (config.SysConfig.DbType.ToLower() == "oracle") { o1 = new FT.DAL.Oracle.OracleDataHelper(dbname, userid, pwd); } else if (config.SysConfig.DbType.ToLower() == "access") { if (pwd.Length > 0) { o1 = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=" + dbname + ";Jet OLEDB:Database Password="******"û���ҵ�����࣬��ͬ����"); } } firstPlugin = false; } }
private void button2_Click(object sender, EventArgs e) { FT.DAL.Access.AccessDataHelper access = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=\\\\" + this.txtShareDbIp.Text.Trim() + "\\db\\db.mdb;Jet OLEDB:Database Password=SQL"); try { if (access.Open()) { XmlDocument doc = new XmlDocument(); doc.Load(Application.ExecutablePath + ".config"); XmlNode node1 = doc.SelectSingleNode(@"//add[@key='" + connKey + "']"); XmlElement ele1 = (XmlElement)node1; ele1.SetAttribute("value", FT.Commons.Security.SecurityFactory.GetSecurity().Encrypt("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=\\\\" + this.txtShareDbIp.Text.Trim() + "\\db\\db.mdb;Jet OLEDB:Database Password=SQL")); doc.Save(Application.ExecutablePath + ".config"); MessageBoxHelper.Show("����ɹ������˳��ؽ���"); access.Close(); } else { MessageBox.Show("����" + this.txtShareDbIp.Text.Trim() + "ʧ��,����Ŀ������Ƿ���ã�\r\n�Ƿ��Ѿ�����Ԥ¼��ϵͳ��db�ļ��У�", "��ʾ"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button1_Click(object sender, EventArgs e) { string ip =this.txtIp.Text.Trim() ; string dbname = this.txtDbName.Text.Trim() ; string userid = this.txtUID.Text.Trim(); string pwd = this.txtPwd.Text.Trim(); if (dbname.Length > 0 && userid.Length > 0) { FT.DAL.IDataAccess access = null; if (this.cbDbType.Text.Trim().ToLower() == "sqlserver") { access = new FT.DAL.SqlServer.SqlServerDataHelper(ip, dbname, userid, pwd); } else if (this.cbDbType.Text.Trim().ToLower() == "oracle") { access = new FT.DAL.Oracle.OracleDataHelper(dbname, userid, pwd); } else if (this.cbDbType.Text.Trim().ToLower() == "access") { if(pwd.Length>0) { access=new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=" + dbname + ";Jet OLEDB:Database Password="******"���Գɹ���", "��ʾ"); access.Close(); } else { MessageBox.Show("����ʧ�ܣ�", "��ʾ"); } } catch (Exception ex) { MessageBoxHelper.Show(ex.ToString()); } } else { MessageBoxHelper.Show("������д���ݿ����͵�½��"); } }
private void btnTestShareDb_Click(object sender, EventArgs e) { FT.DAL.Access.AccessDataHelper access = new FT.DAL.Access.AccessDataHelper("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=\\\\" + this.txtShareDbIp.Text.Trim() + "\\db\\db.mdb;Jet OLEDB:Database Password=SQL"); try { if (access.Open()) { MessageBox.Show("���ӳɹ���", "��ʾ"); access.Close(); } else { MessageBox.Show("����" + this.txtShareDbIp.Text.Trim() + "ʧ��,����Ŀ������Ƿ���ã�\r\n�Ƿ��Ѿ�����Ԥ¼��ϵͳ��db�ļ��У�", "��ʾ"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }