top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Check for Column Name in SqlDataReader object in C# ?

0 votes
321 views
How to Check for Column Name in SqlDataReader object in C# ?
posted Jun 7, 2016 by Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
public static bool HasColumn(IDataRecord dataReader, string columnName)
{
    for (int i = 0; i < dataReader.FieldCount; i++)
    {
        if (dataReader.GetName(i).Equals(columnName, StringComparison.InvariantCultureIgnoreCase))
            return true;
    }
    return false;
}
answer Jun 7, 2016 by Shivaranjini
...