/// <summary> /// Creates a prepared (or compiled) version of the command on the data source. /// </summary> /// <exception cref="T:System.InvalidOperationException">The <see cref="P:System.Data.OleDb.OleDbCommand.Connection"/> is not set. /// -or- The <see cref="P:System.Data.OleDb.OleDbCommand.Connection"/> is not <see cref="M:System.Data.OleDb.OleDbConnection.Open"/>. </exception> /// <filterpriority>2</filterpriority> public override void Prepare() { var channel = m_connection.BeginExecuteCommand(this); try { var dataRequest = CreateRequest(true, false); using (var response = SendCommand(channel, dataRequest, CreateRequestParams(), null)) { var streamHolder = PqlDataConnection.ReaderStreams.Take(m_connection.CancellationTokenSource.Token); try { streamHolder.Item.Attach(response.Stream); using (var reader = new PqlProtocolUtility(m_connection, streamHolder.Item, streamHolder)) { // this will throw if any server exceptions are reported reader.ReadResponse(); } } catch { streamHolder.Dispose(); throw; } } } catch { m_connection.ConfirmExecutionCompletion(false); throw; } }
private int ExecuteNonQuery(StatementType statementType, string entityName, string[] fieldNames, int argCount, IEnumerable <RowData> requestBulk) { var channel = m_connection.BeginExecuteCommand(this); try { var dataRequest = CreateRequest(false, false); var dataRequestBulk = requestBulk == null ? null : CreateRequestBulk(statementType, entityName, fieldNames, argCount, requestBulk); using (var response = SendCommand(channel, dataRequest, CreateRequestParams(), dataRequestBulk)) { var streamHolder = PqlDataConnection.ReaderStreams.Take(m_connection.CancellationTokenSource.Token); try { streamHolder.Item.Attach(response.Stream); using (var reader = new PqlProtocolUtility(m_connection, streamHolder.Item, streamHolder)) { // this will throw if any server exceptions are reported return(reader.ReadResponse().RecordsAffected); } } catch { streamHolder.Dispose(); throw; } } } catch { m_connection.ConfirmExecutionCompletion(false); throw; } }