コード例 #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;
 }