Exemple #1
0
        internal void Open_ChangeDatabase(string value)
        {
            CheckState(ADP.ChangeDatabase);

            // Database name must not be null, empty or whitspace
            if (string.IsNullOrWhiteSpace(value))
            { // MDAC 62679
                throw ADP.EmptyDatabaseName();
            }
            if (1024 < value.Length * 2 + 2)
            {
                throw ADP.DatabaseNameTooLong();
            }
            RollbackDeadTransaction();

            //Set the database
            OdbcConnectionHandle connectionHandle = ConnectionHandle !;

            ODBC32.SQLRETURN retcode = connectionHandle.SetConnectionAttribute3(ODBC32.SQL_ATTR.CURRENT_CATALOG, value, checked ((int)value.Length * 2));

            if (retcode != ODBC32.SQLRETURN.SUCCESS)
            {
                HandleError(connectionHandle, retcode);
            }
        }
Exemple #2
0
        internal void Open_ChangeDatabase(string value)
        {
            ExecutePermission.Demand();
            this.CheckState("ChangeDatabase");
            if ((value == null) || (value.Trim().Length == 0))
            {
                throw ADP.EmptyDatabaseName();
            }
            if (0x400 < ((value.Length * 2) + 2))
            {
                throw ADP.DatabaseNameTooLong();
            }
            this.RollbackDeadTransaction();
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            ODBC32.RetCode retcode = connectionHandle.SetConnectionAttribute3(ODBC32.SQL_ATTR.CURRENT_CATALOG, value, value.Length * 2);
            if (retcode != ODBC32.RetCode.SUCCESS)
            {
                this.HandleError(connectionHandle, retcode);
            }
        }