private int ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, out object executeResult) { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IMultipleResults\n", this.ObjectID); OleDbHResult result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_IMultipleResults, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); if (OleDbHResult.E_NOINTERFACE != result) { this.ExecuteCommandTextErrorHandling(result); return(0); } SafeNativeMethods.Wrapper.ClearErrorInfo(); return(this.ExecuteCommandTextForSingleResult(dbParams, out executeResult)); }
// dbindings handle can't be freed until the output parameters // have been filled in which occurs after the last rowset is released // dbbindings.FreeDataHandle occurs in Cloe private int ExecuteCommandText(out object executeResult) { int retcode; tagDBPARAMS dbParams = null; RowBinding rowbinding = null; Bindings bindings = ParameterBindings; bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { if (null != bindings) { // parameters may be suppressed rowbinding = bindings.RowBinding(); rowbinding.DangerousAddRef(ref mustRelease); // bindings can't be released until after last rowset is released // that is when output parameters are populated // initialize the input parameters to the input databuffer bindings.ApplyInputParameters(); dbParams = new tagDBPARAMS(); dbParams.pData = rowbinding.DangerousGetDataPtr(); dbParams.cParamSets = 1; dbParams.hAccessor = rowbinding.DangerousGetAccessorHandle(); } if ((0 == (CommandBehavior.SingleResult & this.commandBehavior)) && _connection.SupportMultipleResults()) { retcode = ExecuteCommandTextForMultpleResults(dbParams, out executeResult); } else if (0 == (CommandBehavior.SingleRow & this.commandBehavior) || !_executeQuery) { retcode = ExecuteCommandTextForSingleResult(dbParams, out executeResult); } else { retcode = ExecuteCommandTextForSingleRow(dbParams, out executeResult); } } finally { if (mustRelease) { rowbinding.DangerousRelease(); } } return(retcode); }
private int ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, out object executeResult) { Debug.Assert(0 == (CommandBehavior.SingleRow & this.commandBehavior), "SingleRow implies SingleResult"); OleDbHResult hr; hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_IMultipleResults, dbParams, out _recordsAffected, out executeResult); if (OleDbHResult.E_NOINTERFACE != hr) { ExecuteCommandTextErrorHandling(hr); return(ODB.ExecutedIMultipleResults); } SafeNativeMethods.Wrapper.ClearErrorInfo(); return(ExecuteCommandTextForSingleResult(dbParams, out executeResult)); }
private int ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, out object executeResult) { OleDbHResult hr; // (Microsoft.Jet.OLEDB.4.0 returns 0 for recordsAffected instead of -1) if (_executeQuery) { hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRowset, dbParams, out _recordsAffected, out executeResult); } else { hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_NULL, dbParams, out _recordsAffected, out executeResult); } ExecuteCommandTextErrorHandling(hr); return(ODB.ExecutedIRowset); }
private int ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, out object executeResult) { OleDbHResult result; if (this._executeQuery) { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID); result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRowset, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); } else { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_NULL\n", this.ObjectID); result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_NULL, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); } this.ExecuteCommandTextErrorHandling(result); return(1); }
private int ExecuteCommandText(out object executeResult) { tagDBPARAMS dbParams = null; RowBinding binding = null; int num; Bindings parameterBindings = this.ParameterBindings; bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { if (parameterBindings != null) { binding = parameterBindings.RowBinding(); binding.DangerousAddRef(ref success); parameterBindings.ApplyInputParameters(); dbParams = new tagDBPARAMS { pData = binding.DangerousGetDataPtr(), cParamSets = 1, hAccessor = binding.DangerousGetAccessorHandle() }; } if (((CommandBehavior.SingleResult & this.commandBehavior) == CommandBehavior.Default) && this._connection.SupportMultipleResults()) { return(this.ExecuteCommandTextForMultpleResults(dbParams, out executeResult)); } if (((CommandBehavior.SingleRow & this.commandBehavior) == CommandBehavior.Default) || !this._executeQuery) { return(this.ExecuteCommandTextForSingleResult(dbParams, out executeResult)); } num = this.ExecuteCommandTextForSingleRow(dbParams, out executeResult); } finally { if (success) { binding.DangerousRelease(); } } return(num); }
private int ExecuteCommandTextForSingleRow(tagDBPARAMS dbParams, out object executeResult) { Debug.Assert(_executeQuery, "ExecuteNonQuery should always use ExecuteCommandTextForSingleResult"); if (_connection.SupportIRow(this)) { OleDbHResult hr; hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRow, dbParams, out _recordsAffected, out executeResult); if (OleDbHResult.DB_E_NOTFOUND == hr) { SafeNativeMethods.Wrapper.ClearErrorInfo(); return(ODB.ExecutedIRow); } else if (OleDbHResult.E_NOINTERFACE != hr) { ExecuteCommandTextErrorHandling(hr); return(ODB.ExecutedIRow); } } SafeNativeMethods.Wrapper.ClearErrorInfo(); return(ExecuteCommandTextForSingleResult(dbParams, out executeResult)); }
private int ExecuteCommandTextForSingleRow(tagDBPARAMS dbParams, out object executeResult) { Debug.Assert(_executeQuery, "ExecuteNonQuery should always use ExecuteCommandTextForSingleResult"); if (_connection.SupportIRow(this)) { OleDbHResult hr; Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IRow\n", ObjectID); hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRow, dbParams, out _recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", hr, _recordsAffected); if (OleDbHResult.DB_E_NOTFOUND == hr) { // MDAC 76110 SafeNativeMethods.Wrapper.ClearErrorInfo(); return ODB.ExecutedIRow; } else if (OleDbHResult.E_NOINTERFACE != hr) { ExecuteCommandTextErrorHandling(hr); return ODB.ExecutedIRow; } } SafeNativeMethods.Wrapper.ClearErrorInfo(); return ExecuteCommandTextForSingleResult(dbParams, out executeResult); }
private int ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, out object executeResult) { OleDbHResult hr; // MDAC 64465 (Microsoft.Jet.OLEDB.4.0 returns 0 for recordsAffected instead of -1) if (_executeQuery) { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IRowset\n", ObjectID); hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRowset, dbParams, out _recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", hr, _recordsAffected); } else { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_NULL\n", ObjectID); hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_NULL, dbParams, out _recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", hr, _recordsAffected); } ExecuteCommandTextErrorHandling(hr); return ODB.ExecutedIRowset; }
private int ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, out object executeResult) { Debug.Assert(0 == (CommandBehavior.SingleRow & this.commandBehavior), "SingleRow implies SingleResult"); OleDbHResult hr; Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IMultipleResults\n", ObjectID); hr = _icommandText.Execute(ADP.PtrZero, ref ODB.IID_IMultipleResults, dbParams, out _recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", hr, _recordsAffected); if (OleDbHResult.E_NOINTERFACE != hr) { ExecuteCommandTextErrorHandling(hr); return ODB.ExecutedIMultipleResults; } SafeNativeMethods.Wrapper.ClearErrorInfo(); return ExecuteCommandTextForSingleResult(dbParams, out executeResult); }
// dbindings handle can't be freed until the output parameters // have been filled in which occurs after the last rowset is released // dbbindings.FreeDataHandle occurs in Cloe private int ExecuteCommandText(out object executeResult) { int retcode; tagDBPARAMS dbParams = null; RowBinding rowbinding = null; Bindings bindings = ParameterBindings; bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { if (null != bindings) { // parameters may be suppressed rowbinding = bindings.RowBinding(); rowbinding.DangerousAddRef(ref mustRelease); // bindings can't be released until after last rowset is released // that is when output parameters are populated // initialize the input parameters to the input databuffer bindings.ApplyInputParameters(); dbParams = new tagDBPARAMS(); dbParams.pData = rowbinding.DangerousGetDataPtr(); dbParams.cParamSets = 1; dbParams.hAccessor = rowbinding.DangerousGetAccessorHandle(); } if ((0 == (CommandBehavior.SingleResult & this.commandBehavior)) && _connection.SupportMultipleResults()) { retcode = ExecuteCommandTextForMultpleResults(dbParams, out executeResult); } else if (0 == (CommandBehavior.SingleRow & this.commandBehavior) || !_executeQuery) { retcode = ExecuteCommandTextForSingleResult(dbParams, out executeResult); } else { retcode = ExecuteCommandTextForSingleRow(dbParams, out executeResult); } } finally { if (mustRelease) { rowbinding.DangerousRelease(); } } return retcode; }
private int ExecuteCommandTextForSingleRow(tagDBPARAMS dbParams, out object executeResult) { if (this._connection.SupportIRow(this)) { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IRow\n", this.ObjectID); OleDbHResult result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRow, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); if (OleDbHResult.DB_E_NOTFOUND == result) { SafeNativeMethods.Wrapper.ClearErrorInfo(); return 2; } if (OleDbHResult.E_NOINTERFACE != result) { this.ExecuteCommandTextErrorHandling(result); return 2; } } SafeNativeMethods.Wrapper.ClearErrorInfo(); return this.ExecuteCommandTextForSingleResult(dbParams, out executeResult); }
private int ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, out object executeResult) { OleDbHResult result; if (this._executeQuery) { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IRowset\n", this.ObjectID); result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_IRowset, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); } else { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_NULL\n", this.ObjectID); result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_NULL, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); } this.ExecuteCommandTextErrorHandling(result); return 1; }
private int ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, out object executeResult) { Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB> %d#, IID_IMultipleResults\n", this.ObjectID); OleDbHResult result = this._icommandText.Execute(ADP.PtrZero, ref ODB.IID_IMultipleResults, dbParams, out this._recordsAffected, out executeResult); Bid.Trace("<oledb.ICommandText.Execute|API|OLEDB|RET> %08X{HRESULT}, RecordsAffected=%Id\n", result, this._recordsAffected); if (OleDbHResult.E_NOINTERFACE != result) { this.ExecuteCommandTextErrorHandling(result); return 0; } SafeNativeMethods.Wrapper.ClearErrorInfo(); return this.ExecuteCommandTextForSingleResult(dbParams, out executeResult); }
private int ExecuteCommandText(out object executeResult) { tagDBPARAMS dbParams = null; RowBinding binding = null; int num; Bindings parameterBindings = this.ParameterBindings; bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { if (parameterBindings != null) { binding = parameterBindings.RowBinding(); binding.DangerousAddRef(ref success); parameterBindings.ApplyInputParameters(); dbParams = new tagDBPARAMS { pData = binding.DangerousGetDataPtr(), cParamSets = 1, hAccessor = binding.DangerousGetAccessorHandle() }; } if (((CommandBehavior.SingleResult & this.commandBehavior) == CommandBehavior.Default) && this._connection.SupportMultipleResults()) { return this.ExecuteCommandTextForMultpleResults(dbParams, out executeResult); } if (((CommandBehavior.SingleRow & this.commandBehavior) == CommandBehavior.Default) || !this._executeQuery) { return this.ExecuteCommandTextForSingleResult(dbParams, out executeResult); } num = this.ExecuteCommandTextForSingleRow(dbParams, out executeResult); } finally { if (success) { binding.DangerousRelease(); } } return num; }