⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adoqry.ssc

📁 PowerBuilder8.0开发分散式应用所帶的例程
💻 SSC
字号:
<!--SCRIPT PSOBJMOD
    import( site.GetRootDocument().location + "/ObjMod80.ssc" );
    session.active = true;
    InitObjects(session);
-->
<!--SCRIPT // {{ SCRIPT()
    // This class takes as a parameter an ADO record set object.
    // The ADOQuery class implements the same methods as a Dynamo
    // query object, so that you can work with the ADO record set
    // as if it were a Dynamo query object. Some behaviour may
    // differ slightly since the ADO record set object does not
    // support some functionality provided by the Dynamo query
    // object. The Dynamo query object can sometimes support
    // movement backwards through the result set. Backward movement
    // is not supported by the ADO record set, but has been
    // simulated in this class for your convenience. Because
    // backward movement is simulated, it can be inefficient. For this
    // reason, it is recommended that MoveNext be used whenever
    // possible for moving through a result set.
    
    class ADOQuery( rs ) {
        this.position = 0;
        this.rs = rs;
        
        function Execute() {
            // There is no ADO equivalent, so always return false.
            return false;
        }
        this.Execute = Execute;
        
        function GetColumnCount() {
            return this.rs.Fields.Count;
        }
        this.GetColumnCount = GetColumnCount;
        
        function GetColumnIndex( name ) {
            // loop through each field to find proper name
            var columns = this.rs.Fields;
            var size = columns.Count;
            var index = -1;
            var i;
            for( i = 0; i < size; i++ ) {
                if( columns.Item(i).Name == name ) {
                    index = i + 1;
                    break;
                }
            }
            return index;
        }
        this.GetColumnIndex = GetColumnIndex;
        
        function GetColumnLabel( index ) {
            if( index < 1 || index > this.rs.Fields.Count ) {
                return "";
            }
            return this.rs.Fields.Item(index - 1).Name;
        }
        this.GetColumnLabel = GetColumnLabel;
        
        function GetEmpty() {
            return( this.rs.RecordCount == 0 );
        }
        this.GetEmpty = GetEmpty;
        
        function GetErrorCode() {
            // There is no ADO equivalent, so always return 0.
            return 0;
        }
        this.GetErrorCode = GetErrorCode;
        
        function GetErrorInfo() {
            // There is no ADO equivalent, so always return "".
            return "";
        }
        this.GetErrorInfo = GetErrorInfo;
        
        function GetRowCount() {
            return this.rs.RecordCount;
        }
        this.GetRowCount = GetRowCount;
        
        function GetState() {
            // This is no ADO equivalent, so always return "".
            return "";
        }
        this.GetState = GetState;
        
        function MoveFirst() {
            this.rs.MoveFirst();
            this.position = 1;
            return !this.rs.EOF; 
        }
        this.MoveFirst = MoveFirst;
        
        function Move( index ) {
            if( index <= 0 || index > this.rs.RecordCount ) return false;
            if( index < this.position ) {
                if( !this.MoveFirst() ) return false;
            }
            while( this.position < index ) {
                if( this.rs.EOF ) return false;
                this.MoveNext();
            }
            return true;
        }
        this.Move = Move;
        
        function MoveNext() {
            if( this.position == 0 ) {
                return this.MoveFirst();
            }
            this.rs.MoveNext();
            if( this.rs.EOF ) return false;
            this.position++;
            return true;
        }
        this.MoveNext = MoveNext;
        
        function MoveLast() {
            if( this.position == 0 ) {
                this.MoveFirst();
            }
            // Loop to the end of the result set
            while( this.position < this.rs.RecordCount ) {
                if( this.rs.EOF ) return false;
                this.MoveNext();
            }
            return true;
        }
        this.MoveLast = MoveLast;
        
        function MovePrevious() {
            if( this.position < 2 ) return false;
            var previous = this.position - 1;
            this.MoveFirst();
            while( this.position < previous ) {
                if( this.rs.EOF ) return false;
                this.MoveNext();
            }
            return !this.rs.EOF;
        }
        this.MovePrevious = MovePrevious;
        
        function MoveRelative( index ) {
            if( index == 0 ) return true;
            return this.Move( this.position + index );
        }
        this.MoveRelative = MoveRelative;
        
        function Opened() {
            // There is no ADO equivalent, so always return true.
            return( true );
        }
        this.Opened = Opened;
        
        function Close() {
            // There is no ADO equivalent, so always return false.
            return( false );
        }
        this.Close = Close;
        
        function Refresh() {
            // There is no ADO equivalent, so always return false.
            return false;
        }
        this.Refresh = Refresh;
        
        function SetSQL( sql ) {
            // There is no ADO equivalent, so always return false.
            return false;
        }
        this.SetSQL = SetSQL;
             
        function GetValue( index ) {
            // Return the value for the specified column
            if( index < 1 || index > this.rs.Fields.Count ) return "";
            return this.rs.Fields.Item( index - 1 ).Value;
        }
        this.GetValue = GetValue;
        
        function ResultsToXMLString() {
            // There is no ADO equivalent, so always return null.
            return null;
        }
        this.ResultsToXMLString = ResultsToXMLString;
    }
// }}
-->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -