protected override void Dispose(bool ADisposing) { if (FCursor != null) { try { FCursor.Dispose(); } finally { FCursor = null; FRecord = null; } } base.Dispose(ADisposing); }
/// <summary> Closes the current reader and examines the EOF and server cursor handle output parameters. </summary> private void CloseAndProcessFetchResult() { FCursor.Dispose(); FCursor = null; switch ((int)((MSSQLCommand)FCommand).GetParameterValue("@retval")) { case 16: FEOF = true; break; case 0: FEOF = false; break; default: throw new ConnectionException(ConnectionException.Codes.UnableToOpenCursor); } if (FCursorHandle == 0) { MSSQLCommand LCommand = (MSSQLCommand)FCommand; LCommand.ParametersAreAvailable(); // Indicate to the command that now is the time to read any output (user) parameters FCursorHandle = (int)LCommand.GetParameterValue("@cursor"); } }
private bool FEOF; // Indicates that the end of the current fetch cursor is know to be the end of the entire dataset protected override bool InternalNext() { bool LGotRow = FCursor.Read(); if (!LGotRow) { // Either we are at the end of the data set or we are just at the end of the current fetch buffer. We must close the // current reader so that we can get the output params and determine the server cursor handle and the EOF flag. CloseAndProcessFetchResult(); // The EOF flag has been updated, so we can tell whether or not to proceed with a fetch if (!FEOF) { FCursor = ((MSSQLCommand)FCommand).FetchServerCursor(FCursorHandle); FRecord = (IDataRecord)FCursor; // Attempt to read the first row LGotRow = FCursor.Read(); } } return(LGotRow); }