コード例 #1
0
 /// <summary>
 /// NewDataReader
 /// </summary>
 public static IWhizzDataReader NewDataReader(IDataReader reader, string name, DataStorageType storageType)
 {
     IWhizzDataReader dataReader = null;
     switch (storageType)
     {
         case DataStorageType.Firebird:
             dataReader = new FirebirdDataReader(reader, name);
             break;
         case DataStorageType.SQLServer:
             dataReader = new SQLServerDataReader(reader, name);
             break;
     }
     return dataReader;
 }
コード例 #2
0
        /// <summary>
        /// Executes the current command and returns a SafeDataReader 
        /// so the caller can iterate through the returned data.
        /// </summary>
        public IWhizzDataReader ExecuteReader()
        {
            CheckDisposedState();

            //Make sure if the user tries to open a second DataReader on the same
            //connection that we throw an exception.  This is probably due to a
            //programming error which needs to be fixed.
            if (this.DataReader != null)
            {
                throw new Exception();
            }

            FbDataReader reader = null;
            try
            {
                // Execute the reader...
                reader = this.Command.ExecuteReader();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // Make it safe...
            this.DataReader = new FirebirdDataReader(reader, this.connection.Database);

            // Return...
            return this.DataReader;
        }
コード例 #3
0
        /// <summary>
        /// Executes the current command and returns a SafeDataReader 
        /// so the caller can iterate through the returned data.
        /// Specifies a timeout value, in seconds...
        /// </summary>
        public IWhizzDataReader ExecuteReader(int timeOut)
        {
            CheckDisposedState();

            //Make sure if the user tries to open a second DataReader on the same
            //connection that we throw an exception.  This is probably due to a
            //programming error which needs to be fixed.
            if (this.DataReader != null)
            {
                throw new Exception();
            }

            //Execute the datareader and store a reference so that we can close
            //the reader gracefully in the future.

            // Set the timeout...
            this.Command.CommandTimeout = timeOut;

            FbDataReader reader = null;

            try
            {
                // Execute the reader...
                reader = this.Command.ExecuteReader();
            }
            catch (ThreadAbortException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // Make it safe...
            this.DataReader = new FirebirdDataReader(reader, this.connection.Database);

            // Return...
            return this.DataReader;
        }
コード例 #4
0
 /// <summary>
 /// Checks if the data reader object of this FirebirdDBProvider is disposed and, if not, closes it and disposes it.
 /// This is needed for code that plans to execute a reader more than once on the same provider object, as
 /// this FirebirdDBProvider only allows one instance of a reader to exist at a time.
 /// </summary>
 public void CloseDataReader()
 {
     if (this.DataReader != null)
     {
         this.DataReader.Dispose();
         this.DataReader = null;
     }
 }