This might seem insane but I feel compelled to ask. Assume execution of select *
and a resulting SqlDataReader that you read a data row and get N columns. Now read the next row. Is there any chance whatsoever that the order of the columns within these rows will be different?
Consider figure 1 from this MSDN blog. It shows each row has a unique set of column headers for each segment of column data. The Tabular Data Stream Protocol, link from that blog, confirms that there is unique COLINFO and COLMETADATA for each "cell". Why would there that be that duplication unless there is a possibility that it could be different from one row to another?
Does anyone here reference reader[name] rather than reader[int] to avoid such a potential pitfall? Or re-load an array of name/int pairs from each row in case the ordinal changes? I understand using column names is more elegant but is it "highly recommended" for larger datasets returned from a query?