What is the best way of handling trying to get data from a DataReader that has more than one column with the same name?
Because of the amount of work involved and because we don't want to lose support from a vendor by changing the stored procedures we are using to retrieve the data, I am trying to find another way to get access to a column that shows up more than once in a datareader without having to rewrite the stored procedures.
Any Ideas?
EDIT: Ok, the function that actually populates from a datareader is used in multiple places so there is a possibility that the function can be called by different stored procedures. What I did was to do a GetName using the index to check if it is the correct column, and if it is, then pull its value.
Thanks again.
-
Can't you use column ordinals? 0 for the 1st, 1 for the 2nd, and so on?
-
If you know the index of the column, then access it by the index.
-
You will have to reference the column by index no; i.e. reader[5].ToString(); to read the data in column 5.
0 comments:
Post a Comment