/// <summary> /// 연결스트링을 설정합니다. /// </summary> /// <param name="enPro">DB종류</param> /// <param name="strServer"></param> /// <param name="strDB"></param> /// <param name="strID"></param> /// <param name="strPassword"></param> public static string Set_connectionString(enProvider enPro, string strIP, string strDB, string strID, string strPass) { string strConn = string.Empty; switch (enPro) { case enProvider.MSSql: strConn = string.Format("Provider=SQLOLEDB;Data Source={0};initial catalog={1};User Id={2};Password={3}", strIP, strDB, strID, strPass); break; case enProvider.Oracle: strConn = string.Format("Provider=MsdaOra;Data Source={0};User Id={2};Password={3}", strIP, strDB, strID, strPass); break; case enProvider.MDB: strConn = string.Format("Provider=Micorosoft.jet.OLEDB.4.0;Data Source={0}", strIP, strDB, strID, strPass); break; case enProvider.Excel: //strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\" ", strIP); strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='{0}';Extended Properties=Excel 8.0", strIP, strDB, strID, strPass); break; case enProvider.CSV: strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='text;HDR=Yes;FMT=Delimited", strIP, strDB, strID, strPass); break; case enProvider.Sybase: strConn = string.Format("Provider=ASEOLEDB;Data Source={0};Catalog={1};User Id={2};Password={3};", strIP, strDB, strID, strPass); //string.Format("Provider=ASEOLEDB;Server Name={0};Server Port Address={1};Initial Catalog=DIRECTORY;User ID={2};Password={3}", strIP, strDB, strID, strPass); break; } return(strConn); }
/// <summary> /// 연결스트링을 설정합니다. /// </summary> /// <param name="enPro">DB종류</param> /// <param name="strServer"></param> /// <param name="strDB"></param> /// <param name="strID"></param> /// <param name="strPassword"></param> public void Set_ConnectionString(enProvider enPro, string strIP, string strDB, string strID, string strPass) { switch (enPro) { case enProvider.MSSql: this.connectionString = string.Format("Provider=SQLOLEDB;Data Source={0};initial catalog={1};User Id={2};Password={3}", strIP, strDB, strID, strPass); break; case enProvider.Oracle: this.connectionString = string.Format("Provider=MsdaOra;Data Source={0};User Id={2};Password={3}", strIP, strDB, strID, strPass); break; case enProvider.MDB: this.connectionString = string.Format("Provider=Micorosoft.jet.OLEDB.4.0;Data Source={0}", strIP, strDB, strID, strPass); break; case enProvider.Excel: this.connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='{0}';Extended Properties=Excel 8.0", strIP, strDB, strID, strPass); //this.connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='{0}';Extended Properties=Excel 12.0;Imex=1", strIP); //this.connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\" ", strIP); break; case enProvider.CSV: this.connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='{0}';Extended Properties='text;HDR=Yes;FMT=Delimited;'", strIP, strDB, strID, strPass); break; case enProvider.Sybase: this.connectionString = string.Format("Provider=ASEOLEDB;Data Source={0};Catalog={1};User Id={2};Password={3};", strIP, strDB, strID, strPass); //string.Format("Provider=ASEOLEDB;Server Name={0};Server Port Address={1};Initial Catalog=DIRECTORY;User ID={2};Password={3}", strIP, strDB, strID, strPass); break; case enProvider.db2: this.connectionString = string.Format("Provider=IBMDA400;Data Source={0};User id={2};password={3};Default Collection={1};Catalog Library List=*LIBL;", strIP, strDB, strID, strPass); break; case enProvider.ACCDB: this.connectionString = string.Format("provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", strIP, strDB, strID, strPass); break; } }
/// <summary> /// 객체를 생성 하면서 Connection String 만든다. /// </summary> /// <param name="strIP"></param> /// <param name="strDB"></param> /// <param name="strID"></param> /// <param name="strPassword"></param> public OleDB(enProvider enPro, string strIP, string strDB, string strID, string strPassword) { Set_ConnectionString(enPro, strIP, strDB, strID, strPassword); }