Exemplo n.º 1
0
 static DsDbConnConfig()
 {
     DatabaseAccess dbAccess = new DatabaseAccess(DatabaseConnection.Default);
     using (DataTable dt = dbAccess.ExecuteDataTable("SELECT * FROM dsk_db_cfg")) {
         if (dt != null) {
             foreach (DataRow dr in dt.Rows) {
                 string name = dr["DB_NAME"].ToString();
                 string ip = dr["DB_IP"].ToString();
                 string database = dr["SID"].ToString();
                 int port = Convert.ToInt32(dr["DB_PORT"]);
                 string userId = dr["USR_NAME"].ToString();
                 string pwd = dr["USR_PWD"].ToString();
                 DatabaseType typ;
                 switch (dr["DB_TYP"].ToString()) {
                     case "1":
                         typ = DatabaseType.Oracle;
                         break;
                     case "2":
                         typ = DatabaseType.SQLServer;
                         break;
                     case "3":
                         typ = DatabaseType.MySql;
                         break;
                     default:
                         typ = DatabaseType.Oracle;
                         break;
                 }
                 DatabaseConnection conn = new DatabaseConnection(ip, port, database, userId, pwd, typ);
                 _dic[name] = conn;
             }
         }
     }
 }
Exemplo n.º 2
0
 public DataTable ExecuteDataTable(string statementName, int pageSize, int pageIndex, out int pageCount, out int recordCount, params DatabaseParameter[] dbParams)
 {
     try {
         string sql = GenerateSql(statementName);
         DatabaseAccess access = new DatabaseAccess(_conn);
         return access.ExecuteDataTable(sql, pageSize, pageIndex, out  pageCount, out  recordCount, dbParams);
     }
     catch (Exception ex) {
         throw new Exception(string.Format("Sql执行出错,节点名\"{0}\" ({1})", statementName, _sqlMapPath), ex);
     }
 }