Agnes,
Well, with DataTables, there is a Columns collection that has a Contains() method, so that you can query if a column by that name exists. Apparently there is no Contains() method in the DataReader. You could, however, create your own method do to this.
Off the top of my head (don't have VS up at the moment):
public bool Contains(string ColumnName)
for (int i=0; i < myReader.FieldCount; i++)
{
if (myReader.GetName[i] == ColumnName)
return true;
}
return false;
}
And of course you'd use it like this:
if (this.Contains("kcno"))
pKcno = myReader.Item("kcno");
~~Bonnie
>pKcno = myReader.Item("kcno") <--it will return error when the field "kcno" doesn't exist
>
>any method to check the field exist or not first , if not exist, I want to skip the above statement.
>
>Thanks