internal OleDbHResult CreateAccessor(UnsafeNativeMethods.IAccessor iaccessor, int flags, ColumnBinding[] bindings) { OleDbHResult result = OleDbHResult.S_OK; int[] rgStatus = new int[this.BindingCount()]; this._iaccessor = iaccessor; Bid.Trace("<oledb.IAccessor.CreateAccessor|API|OLEDB>\n"); result = iaccessor.CreateAccessor(flags, (IntPtr) rgStatus.Length, this, (IntPtr) this._dataLength, out this._accessorHandle, rgStatus); Bid.Trace("<oledb.IAccessor.CreateAccessor|API|OLEDB|RET> %08X{HRESULT}\n", result); for (int i = 0; i < rgStatus.Length; i++) { if (rgStatus[i] != 0) { if (4 == flags) { throw ODB.BadStatus_ParamAcc(bindings[i].ColumnBindingOrdinal, (DBBindStatus) rgStatus[i]); } if (2 == flags) { throw ODB.BadStatusRowAccessor(bindings[i].ColumnBindingOrdinal, (DBBindStatus) rgStatus[i]); } } } return result; }
EnhancedColumnBinding(ColumnBinding Column) { col = Column; }
internal OleDbHResult CreateAccessor(UnsafeNativeMethods.IAccessor iaccessor, int flags, ColumnBinding[] bindings) { OleDbHResult hr = 0; int[] rowBindStatus = new int[BindingCount()]; _iaccessor = iaccessor; Bid.Trace("<oledb.IAccessor.CreateAccessor|API|OLEDB>\n"); hr = iaccessor.CreateAccessor(flags, (IntPtr)rowBindStatus.Length, this, (IntPtr)_dataLength, out _accessorHandle, rowBindStatus); // MDAC 69530 Bid.Trace("<oledb.IAccessor.CreateAccessor|API|OLEDB|RET> %08X{HRESULT}\n", hr); for (int k = 0; k < rowBindStatus.Length; ++k) { if (DBBindStatus.OK != (DBBindStatus)rowBindStatus[k]) { if (ODB.DBACCESSOR_PARAMETERDATA == flags) { throw ODB.BadStatus_ParamAcc(bindings[k].ColumnBindingOrdinal, (DBBindStatus)rowBindStatus[k]); } else if (ODB.DBACCESSOR_ROWDATA == flags) { throw ODB.BadStatusRowAccessor(bindings[k].ColumnBindingOrdinal, (DBBindStatus)rowBindStatus[k]); } else Debug.Assert(false, "unknown accessor buffer"); } } return hr; }
internal ColumnBinding[] SetBindings(OleDbDataReader dataReader, Bindings bindings, int indexStart, int indexForAccessor, OleDbParameter[] parameters, tagDBBINDING[] dbbindings, bool ifIRowsetElseIRow) { Debug.Assert(null != bindings, "null bindings"); Debug.Assert(dbbindings.Length == BindingCount(), "count mismatch"); bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { DangerousAddRef(ref mustRelease); IntPtr buffer = DangerousGetHandle(); for(int i = 0; i < dbbindings.Length; ++i) { IntPtr ptr = ADP.IntPtrOffset(buffer, (i * ODB.SizeOf_tagDBBINDING)); Marshal.StructureToPtr(dbbindings[i], ptr, false/*deleteold*/); } } finally { if (mustRelease) { DangerousRelease(); } } ColumnBinding[] columns = new ColumnBinding[dbbindings.Length]; for(int indexWithinAccessor = 0; indexWithinAccessor < columns.Length; ++indexWithinAccessor) { int index = indexStart + indexWithinAccessor; OleDbParameter parameter = ((null != parameters) ? parameters[index] : null); columns[indexWithinAccessor] = new ColumnBinding( dataReader, index, indexForAccessor, indexWithinAccessor, parameter, this, bindings, dbbindings[indexWithinAccessor], _headerLength, ifIRowsetElseIRow); } return columns; }
internal ColumnBinding[] SetBindings(OleDbDataReader dataReader, Bindings bindings, int indexStart, int indexForAccessor, OleDbParameter[] parameters, tagDBBINDING[] dbbindings, bool ifIRowsetElseIRow) { bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { base.DangerousAddRef(ref success); IntPtr handle = base.DangerousGetHandle(); for (int j = 0; j < dbbindings.Length; j++) { IntPtr ptr = ADP.IntPtrOffset(handle, j * ODB.SizeOf_tagDBBINDING); Marshal.StructureToPtr(dbbindings[j], ptr, false); } } finally { if (success) { base.DangerousRelease(); } } ColumnBinding[] bindingArray = new ColumnBinding[dbbindings.Length]; for (int i = 0; i < bindingArray.Length; i++) { int index = indexStart + i; OleDbParameter parameter = (parameters != null) ? parameters[index] : null; bindingArray[i] = new ColumnBinding(dataReader, index, indexForAccessor, i, parameter, this, bindings, dbbindings[i], this._headerLength, ifIRowsetElseIRow); } return bindingArray; }