예제 #1
0
        public static bool ConnectDataBase()
        {
            if (DBHelper == null) {
                string ip = IniHelper.ReadINI("database", "ip");
                string port = IniHelper.ReadINI("database", "port");
                string database = IniHelper.ReadINI("database", "database");
                string username = IniHelper.ReadINI("database", "username");
                string password = IniHelper.ReadINI("database", "password");
                string type = IniHelper.ReadINI("database", "type");

                switch (type.ToLower()) {
                    case "access":
                        DBHelper = new AccessHelper();
                        database = Environment.CurrentDirectory + "\\" + database;
                        break;
                    case "sqlserver":
                    default:
                        DBHelper = new SqlserverHelper();
                        break;
                }
                DBHelper.SetConnInfoString(ip, port, database, username, password);
            }

            return DBHelper.TestConnect();
        }
예제 #2
0
파일: DBManager.cs 프로젝트: whw123/spatial
 public static bool ConnectCJDB(string ip, string port, string database, string username, string password, string type)
 {
     switch (type.ToLower()) {
         case "oracle":
             DBHelperCJ = new OracleHelper();
             break;
         case "sqlserver":
         default:
             DBHelperCJ = new SqlserverHelper();
             break;
     }
     DBHelperCJ.SetConnInfoString(ip, port, database, username, password);
     return DBHelperCJ.TestConnect();
 }