コード例 #1
0
        /// <summary>
        /// Get Paged Records
        /// </summary>
        /// <param name="query"></param>
        /// <param name="source"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="cursorType"></param>
        /// <param name="lockType"></param>
        /// <param name="options"></param>
        /// <param name="cursorLocation"></param>
        /// <returns></returns>
        public Recordset GetPagedRecords(string query,
                                         DataSource source,
                                         int pageIndex,
                                         int pageSize = 100,
                                         CursorTypeEnum cursorType         = CursorTypeEnum.adOpenDynamic,
                                         LockTypeEnum lockType             = LockTypeEnum.adLockOptimistic,
                                         CommandTypeEnum options           = CommandTypeEnum.adCmdText,
                                         CursorLocationEnum cursorLocation = CursorLocationEnum.adUseClient)
        {
            _connection = new Connection();

            var cnStr = GetConnectionString(source);

            _connection.Open(cnStr, null, null, 0);

            _recordSet = new Recordset
            {
                CursorLocation = cursorLocation,
                CacheSize      = pageSize,
                PageSize       = pageSize
            };

            //_recordSet.Open(query,_connection, cursorType, lockType, (int)options);
            _recordSet.Open(query, _connection);

            if (_recordSet.RecordCount != 0)
            {
                _recordSet.AbsolutePage = (PositionEnum)pageIndex;
            }
            return(_recordSet);
        }
コード例 #2
0
        /// <summary>
        /// Sets the cursor location to an specific connection
        /// </summary>
        /// <param name="connection">The connection to assign the inforrmation from</param>
        /// <param name="location">The cursor location to be assingned</param>
        public static void SetCursorLocation(DbConnection connection, CursorLocationEnum location)
        {
            Dictionary <string, object> thevalue = null;
            object actuallocation = null;

            settings.TryGetValue(connection, out thevalue);
            if (thevalue == null)
            {
                thevalue = new Dictionary <string, object>();
                thevalue.Add(CURSOR_LOCATION_KEY, location);
                settings.Add(connection, thevalue);
            }
            else
            {
                thevalue.TryGetValue(CURSOR_LOCATION_KEY, out actuallocation);
                if (actuallocation == null)
                {
                    thevalue.Add(CURSOR_LOCATION_KEY, location);
                }
                else
                {
                    thevalue[CURSOR_LOCATION_KEY] = location;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the cursor location assigned to an specific connection
        /// </summary>
        /// <param name="connection">The connection to get the inforrmation from</param>
        /// <returns>The cursor location asigned to the connection</returns>
        public static CursorLocationEnum GetCursorLocation(DbConnection connection)
        {
            CursorLocationEnum          result   = CursorLocationEnum.adUseClient;
            Dictionary <string, object> thevalue = null;
            object actuallocation = null;

            settings.TryGetValue(connection, out thevalue);
            if (thevalue == null)
            {
                SetCursorLocation(connection, result);
            }
            else
            {
                thevalue.TryGetValue(CURSOR_LOCATION_KEY, out actuallocation);
                if (actuallocation == null)
                {
                    thevalue.Add(CURSOR_LOCATION_KEY, result);
                }
                else
                {
                    result = (CursorLocationEnum)actuallocation;
                }
            }
            return(result);
        }
コード例 #4
0
        public Recordset CreateRecordset(SqlFrag frag, CommandTypeEnum eCmdType = CommandTypeEnum.adCmdText,
                                         CursorLocationEnum eCursorLoc          = CursorLocationEnum.adUseClient, CursorTypeEnum eCursorType = CursorTypeEnum.adOpenDynamic,
                                         LockTypeEnum eLockType = LockTypeEnum.adLockOptimistic, ExecuteOptionEnum eExecOptions              = ExecuteOptionEnum.adOptionUnspecified)
        {
            ADODB.Command SqlCmd   = GenerateCommand(eCmdType, frag);
            Recordset     rRecords = new Recordset();

            rRecords.CursorLocation = eCursorLoc;

            rRecords.Open(SqlCmd, Type.Missing, eCursorType, eLockType, (int)eExecOptions);
            return(rRecords);
        }
コード例 #5
0
        /// <summary>
        /// Get Records
        /// </summary>
        /// <param name="query"></param>
        /// <param name="source"></param>
        /// <param name="cursorType"></param>
        /// <param name="lockType"></param>
        /// <param name="options"></param>
        /// <param name="cursorLocation"></param>
        /// <returns>RecordSet</returns>
        public Recordset GetRecords(string query,
                                    DataSource source,
                                    CursorTypeEnum cursorType         = CursorTypeEnum.adOpenDynamic,
                                    LockTypeEnum lockType             = LockTypeEnum.adLockOptimistic,
                                    CommandTypeEnum options           = CommandTypeEnum.adCmdText,
                                    CursorLocationEnum cursorLocation = CursorLocationEnum.adUseClient)
        {
            _connection = new Connection();

            var cnStr = GetConnectionString(source);

            _connection.Open(cnStr, null, null, 0);

            _recordSet = new Recordset {
                CursorLocation = cursorLocation
            };

            _recordSet.Open(query, _connection, cursorType, lockType, (int)options);
            return(_recordSet);
        }
コード例 #6
0
 /// <summary>
 /// Sets the cursor location to an specific connection
 /// </summary>
 /// <param name="connection">The connection to assign the inforrmation from</param>
 /// <param name="location">The cursor location to be assingned</param>
 public static void SetCursorLocation(DbConnection connection, CursorLocationEnum location)
 {
     Dictionary<string,object> thevalue = null;
     object actuallocation = null;
     settings.TryGetValue(connection, out thevalue);
     if (thevalue == null)
     {
         thevalue = new Dictionary<string, object>();
         thevalue.Add(CURSOR_LOCATION_KEY, location);
         settings.Add(connection, thevalue);
     }
     else
     {
         thevalue.TryGetValue(CURSOR_LOCATION_KEY, out actuallocation);
         if (actuallocation == null)
             thevalue.Add(CURSOR_LOCATION_KEY, location);
         else
             thevalue[CURSOR_LOCATION_KEY] = location;
     }
 }
コード例 #7
0
        /// <summary>
        /// Get the record count
        /// </summary>
        /// <param name="query"></param>
        /// <param name="source"></param>
        /// <param name="cursorType"></param>
        /// <param name="lockType"></param>
        /// <param name="options"></param>
        /// <param name="cursorLocation"></param>
        /// <returns></returns>
        public short GetRecordCount(string query,
                                    DataSource source,
                                    CursorTypeEnum cursorType         = CursorTypeEnum.adOpenDynamic,
                                    LockTypeEnum lockType             = LockTypeEnum.adLockOptimistic,
                                    CommandTypeEnum options           = CommandTypeEnum.adCmdText,
                                    CursorLocationEnum cursorLocation = CursorLocationEnum.adUseClient)
        {
            _connection = new Connection();

            var cnStr = GetConnectionString(source);

            _connection.Open(cnStr, null, null, 0);

            _recordSet = new Recordset {
                CursorLocation = cursorLocation
            };

            _recordSet.Open(query, _connection);

            var returnValue = (short)_recordSet.RecordCount;

            _recordSet = null;
            return(returnValue);
        }
コード例 #8
0
 public static void setCursorLocation(this DbConnection instance, CursorLocationEnum CursorLocation)
 {
     UpgradeHelpers.Helpers.NotUpgradedHelper.NotifyNotUpgradedElement("ADODB.Connection.CursorLocation");
 }