JetRetrieveColumn() public static méthode

Retrieves a single column value from the current record. The record is that record associated with the index entry at the current position of the cursor. Alternatively, this function can retrieve a column from a record being created in the cursor copy buffer. This function can also retrieve column data from an index entry that references the current record. In addition to retrieving the actual column value, JetRetrieveColumn can also be used to retrieve the size of a column, before retrieving the column data itself so that application buffers can be sized appropriately.
The RetrieveColumnAs functions provide datatype-specific retrieval functions.
public static JetRetrieveColumn ( JET_SESID sesid, JET_TABLEID tableid, JET_COLUMNID columnid, byte data, int dataSize, int &actualDataSize, RetrieveColumnGrbit grbit, JET_RETINFO retinfo ) : JET_wrn
sesid JET_SESID The session to use.
tableid JET_TABLEID The cursor to retrieve the column from.
columnid JET_COLUMNID The columnid to retrieve.
data byte The data buffer to be retrieved into.
dataSize int The size of the data buffer.
actualDataSize int Returns the actual size of the data buffer.
grbit RetrieveColumnGrbit Retrieve column options.
retinfo JET_RETINFO /// If pretinfo is give as NULL then the function behaves as though an itagSequence /// of 1 and an ibLongValue of 0 (zero) were given. This causes column retrieval to /// retrieve the first value of a multi-valued column, and to retrieve long data at /// offset 0 (zero). ///
Résultat JET_wrn
        /// <summary>
        /// Sets the length of the stream.
        /// </summary>
        /// <param name="value">The desired length, in bytes.</param>
        public override void SetLength(long value)
        {
            if (value > MaxLongValueSize || value < 0)
            {
                throw new ArgumentOutOfRangeException("value", value, "A LongValueStream cannot be longer than 0x7FFFFFF or less than 0 bytes");
            }

            if (value < this.Length && value > 0)
            {
                // BUG: Shrinking the column multiple times and then growing it can sometimes hit an unpleasant
                // ESENT defect which causes a hang. To make sure we never have that problem we read out the data,
                // and insert into a new long-value. This is not efficient.
                var data    = new byte[value];
                var retinfo = new JET_RETINFO {
                    itagSequence = this.Itag, ibLongValue = 0
                };
                int actualDataSize;
                Api.JetRetrieveColumn(
                    this.sesid,
                    this.tableid,
                    this.columnid,
                    data,
                    data.Length,
                    out actualDataSize,
                    RetrieveGrbit,
                    retinfo);

                var setinfo = new JET_SETINFO {
                    itagSequence = this.Itag
                };
                Api.JetSetColumn(this.sesid, this.tableid, this.columnid, data, data.Length, SetColumnGrbit.None, setinfo);
            }
            else
            {
                var setinfo = new JET_SETINFO {
                    itagSequence = this.Itag
                };
                SetColumnGrbit grbit = (0 == value) ? SetColumnGrbit.ZeroLength : SetColumnGrbit.SizeLV;
                Api.JetSetColumn(this.sesid, this.tableid, this.columnid, null, checked ((int)value), grbit, setinfo);
            }

            // Setting the length moves the offset back to the end of the data
            if (this.ibLongValue > value)
            {
                this.ibLongValue = checked ((int)value);
            }
        }
        /// <summary>
        /// Reads a sequence of bytes from the current stream and advances the
        /// position within the stream by the number of bytes read.
        /// </summary>
        /// <param name="buffer">The buffer to read into.</param>
        /// <param name="offset">The offset in the buffer to read into.</param>
        /// <param name="count">The number of bytes to read.</param>
        /// <returns>The number of bytes read into the buffer.</returns>
        public override int Read(byte[] buffer, int offset, int count)
        {
            CheckBufferArguments(buffer, offset, count);

            if (this.ibLongValue >= this.Length)
            {
                return(0);
            }

            int length;
            var retinfo = new JET_RETINFO {
                itagSequence = this.Itag, ibLongValue = this.ibLongValue
            };

            Api.JetRetrieveColumn(this.sesid, this.tableid, this.columnid, buffer, count, offset, out length, RetrieveGrbit, retinfo);
            int bytesRead = Math.Min(length, count);

            checked
            {
                this.ibLongValue += bytesRead;
            }

            return(bytesRead);
        }