0
Answer

IDataReader getvalue

Srini

Srini

16y
3.8k
1

I am reading an excel file using ADO.Net. In a column, my first value is nothing and the rest of the values are numbers. But when I read values, I am getting all empty strings. If I replace my first value with some random number, then I am able to read all the values.

My assumption is that IDataReader is detecting the type by its first value and applying it to rest of the values. Is there a way to tell it to assume everything to be strings? Or any other solution to this problem. (Note: I gottu use DataReader because a lot of the logic in the base classes is based on it and I cannot change it.)

[CODE]
while (dreader.Read())
{
                    if (ProcessRecord(dreader))
                        bError = true;
}


ProcessRecord(IDataReader dr)
{
string value = dr.GetValue(0).ToString();
}
[CODE]