Пример #1
0
 public OracleDatabase(DatabaseCredential credential)
     : base(credential)
 {
     this.DBTransaction = null;
     this.DBConnection  = new OracleConnection();
     this.DBConnection.ConnectionString = credential.ConnectionString;
     this.KeepConnection = false;
     //ãªé¡ÒÃá»Å§ DataType ¢Í§ Oracle
     this.DataTypeConverter = new OracleDataTypeConverter();
 }
Пример #2
0
        public SqlDatabase(DatabaseCredential credential)
            : base(credential)
        {
            this.DBTransaction = null;
            this.DBConnection  = new SqlConnection();
            this.DBConnection.ConnectionString = credential.ConnectionString;
            this.KeepConnection = false;
            //ใช้การแปลง DataType ของ SQLServer
            this.DataTypeConverter = new SqlDataTypeConverter();

            this.m_strOleDbConnectionString = credential.OleDbConnectionString;
        }
Пример #3
0
        /// <summary>
        /// Test connection to databse.
        /// </summary>
        /// <param name="credential">Credential.</param>
        /// <returns>If test successful will return null value. Otherwise return the error item.</returns>
        public static ErrorItem TestConnection(DatabaseCredential credential)
        {
            Database db = CreateDatabase(credential);

            try
            {
                db.Open();
                db.Close();
                return(null);
            }
            catch (Exception)
            {
                ErrorItem error = new ErrorItem(null, ResourceBundle.MESSAGES.SYS00001.Key, ResourceBundle.MESSAGES.SYS00001.Value);
                return(error);
            }
        }
Пример #4
0
        /// <summary>
        /// Create instance to connect database.
        /// </summary>
        /// <param name="credential"></param>
        /// <returns>If can create instance return Database object. Otherwise return null.</returns>
        public static Database CreateDatabase(DatabaseCredential credential)
        {
            Database database = null;

            switch (credential.Provider)
            {
            case DatabaseProvider.ORACLE:
                database = new OracleDatabase(credential);
                break;

            case DatabaseProvider.SQLSERVER:
                database = new SqlDatabase(credential);
                break;
            }

            return(database);
        }
Пример #5
0
 internal Database(DatabaseCredential credential)
 {
     this.m_databaseCredential = credential;
 }