Link to home
Start Free TrialLog in
Avatar of clickclickbang
clickclickbang

asked on

Check If Column Exists In An IDataReader Before Calling It

Experts,

Is there any easy way to check if a column exists within an IDataReader before calling it? I'm obviously attempting to avoid the System.IndexOutOfRangeException. I know I can iterate through the GetSchemaTable() to find it but was wondering if there was an easier way.

Thanks much!

~ C
Avatar of p_davis
p_davis

if(reader["columnName"] != null)

ASKER CERTIFIED SOLUTION
Avatar of SprudeVI
SprudeVI
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of clickclickbang

ASKER

Thanks for the tip!