DataReader with double column names

What is the best way to handle trying to get data from a DataReader with more than one column of the same name?

Due to the amount of work involved and because we don't want to lose vendor support by changing the stored procedures we use to retrieve data, I'm trying to find another way to access a column that appears more than once in a datareader without the need to rewrite stored procedures.

Any ideas?

EDIT: Okay, the function that is actually populated from the datareader is used in multiple places, so there is a possibility that the function could be called by different stored procedures. What I did was do GetName using the index to check if it is the correct column and if so, pull out its value.

+1


source to share


3 answers


If you know the index of a column, then refer to it by index.



+3


source


Can't you use columns? 0 for the 1st, 1 for the second, etc.?



+1


source


You will need to reference the column at index no; those. reader [5]. ToString (); to read the data in column 5.

+1


source







All Articles