Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No, because the <code>SqlDataReader</code> is forward only. As far as I know, the best you can do is open the reader with <code>KeyInfo</code> and inspect the schema data table created with the reader's <code>GetSchemaTable</code> method (or just inspect the fields, which is easier, but less reliable).</p> <p>I spent a couple of days on this. I ended up just living with the physical order dependency. I heavily commented both the code method and the stored procedure with <code>!!!IMPORTANT!!!</code>, and included an <code>#If...#End If</code> to output the result sets when needed to validate the stored procedure output.</p> <p>The following code snippet may help you. </p> <h3>Helpful Code</h3> <pre><code> Dim fContainsNextResult As Boolean Dim oReader As DbDataReader = Nothing oReader = Me.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.KeyInfo) #If DEBUG_ignore Then 'load method of data table internally advances to the next result set 'therefore, must check to see if reader is closed instead of calling next result Do Dim oTable As New DataTable("Table") oTable.Load(oReader) oTable.WriteXml("C:\" + Environment.TickCount.ToString + ".xml") oTable.Dispose() Loop While oReader.IsClosed = False 'must re-open the connection Me.SelectCommand.Connection.Open() 'reload data reader oReader = Me.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.KeyInfo) #End If Do Dim oSchemaTable As DataTable = oReader.GetSchemaTable '!!!IMPORTANT!!! PopulateTable expects the result sets in a specific order ' Therefore, if you suddenly start getting exceptions that only a novice would make ' the stored procedure has been changed! PopulateTable(oReader, oDatabaseTable, _includeHiddenFields) fContainsNextResult = oReader.NextResult Loop While fContainsNextResult </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload