المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : DbDataReader: Matching fields to order or occurrence?



C# Programming
07-27-2011, 06:40 PM
I have to read an excel file and ensure the columns are in their correct order (the file is created manually and sometimes, columns are inserted in the incorrect order). I'm reading the file via microsoft jet oledb 4.0. I then insert the values into a DbDataReader.

I now have to check to see if each column is in it's propper position. So, as of now, I have the following to start with (The data reader field names are based on the column header names of the excel file):
using (DbDataReader dr = command.ExecuteReader()) { while (dr.Read()) { String col1 = dr["OrderId"]; } }
But my question is, how do I ensure dr["OrderId"] is the 1st field within the dbDataReader?

Thanks