public static JetSetColumn ( JET_SESID sesid, JET_TABLEID tableid, JET_COLUMNID columnid, byte data, int dataSize, SetColumnGrbit grbit, JET_SETINFO setinfo ) : void | ||
sesid | JET_SESID | The session which is performing the update. |
tableid | JET_TABLEID | The cursor to update. An update should be prepared. |
columnid | JET_COLUMNID | The columnid to set. |
data | byte | The data to set. |
dataSize | int | The size of data to set. |
grbit | SetColumnGrbit | SetColumn options. |
setinfo | JET_SETINFO | Used to specify itag or long-value offset. |
리턴 | void |
/// <summary> /// The JetSetColumn function modifies a single column value in a modified record to be inserted or to /// update the current record. It can overwrite an existing value, add a new value to a sequence of /// values in a multi-valued column, remove a value from a sequence of values in a multi-valued column, /// or update all or part of a long value (a column of type <see cref="JET_coltyp.LongText"/> /// or <see cref="JET_coltyp.LongBinary"/>). /// </summary> /// <remarks> /// This is an internal-only version of the API that takes a data buffer and an offset into the buffer. /// </remarks> /// <param name="sesid">The session which is performing the update.</param> /// <param name="tableid">The cursor to update. An update should be prepared.</param> /// <param name="columnid">The columnid to set.</param> /// <param name="data">The data to set.</param> /// <param name="dataSize">The size of data to set.</param> /// <param name="dataOffset">The offset in the data buffer to set data from.</param> /// <param name="grbit">SetColumn options.</param> /// <param name="setinfo">Used to specify itag or long-value offset.</param> /// <returns>A warning value.</returns> public static JET_wrn JetSetColumn(JET_SESID sesid, JET_TABLEID tableid, JET_COLUMNID columnid, byte[] data, int dataSize, int dataOffset, SetColumnGrbit grbit, JET_SETINFO setinfo) { if (dataOffset < 0 || (null != data && 0 != dataSize && dataOffset >= data.Length) || (null == data && dataOffset != 0)) { throw new ArgumentOutOfRangeException( "dataOffset", dataOffset, "must be inside the data buffer"); } if (null != data && dataSize > checked (data.Length - dataOffset) && (SetColumnGrbit.SizeLV != (grbit & SetColumnGrbit.SizeLV))) { throw new ArgumentOutOfRangeException( "dataSize", dataSize, "cannot be greater than the length of the data (unless the SizeLV option is used)"); } unsafe { fixed(byte *pointer = data) { return(Api.JetSetColumn(sesid, tableid, columnid, new IntPtr(pointer + dataOffset), dataSize, grbit, setinfo)); } } }
/// <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> /// Writes a sequence of bytes to the current stream and advances the current /// position within this stream by the number of bytes written. /// </summary> /// <param name="buffer">The buffer to write from.</param> /// <param name="offset">The offset in the buffer to write.</param> /// <param name="count">The number of bytes to write.</param> public override void Write(byte[] buffer, int offset, int count) { CheckBufferArguments(buffer, offset, count); int length = checked ((int)this.Length); JET_SETINFO setinfo; int newIbLongValue = checked (this.ibLongValue + count); // If our current position is beyond the end of the LV extend // the LV to the write point if (this.ibLongValue > length) { setinfo = new JET_SETINFO { itagSequence = this.Itag }; Api.JetSetColumn(this.sesid, this.tableid, this.columnid, null, this.ibLongValue, SetColumnGrbit.SizeLV, setinfo); length = this.ibLongValue; } SetColumnGrbit grbit; if (this.ibLongValue == length) { grbit = SetColumnGrbit.AppendLV; } else if (newIbLongValue >= length) { grbit = SetColumnGrbit.OverwriteLV | SetColumnGrbit.SizeLV; } else { grbit = SetColumnGrbit.OverwriteLV; } setinfo = new JET_SETINFO { itagSequence = this.Itag, ibLongValue = this.ibLongValue }; Api.JetSetColumn(this.sesid, this.tableid, this.columnid, buffer, count, offset, grbit, setinfo); checked { this.ibLongValue += count; } }