A
Andrei Badea
Hi all,
it seems there's no easy way to find out whether a SqlDataReader contains a
field (given the field name). It has the GetOrdinal() method, but it throws
an exception if the readed doesn't contain the field. I could probably use
the GetSchemaTable method, but it seems it's a little too complicated for
what I want to do. Deep in the System.Data namespace there's a class names
FieldNameLookup which is used by SqlDataReader.GetOrdinal() to lookup the
field names, and it also contains an IndexOfName() method, which returns -1
if the field name is unknown. I can't understand why SqlDataReader doesn't
also expose a method like this (since it's easy and possible to do it). Or
am I missing something?
Regards,
Andrei
it seems there's no easy way to find out whether a SqlDataReader contains a
field (given the field name). It has the GetOrdinal() method, but it throws
an exception if the readed doesn't contain the field. I could probably use
the GetSchemaTable method, but it seems it's a little too complicated for
what I want to do. Deep in the System.Data namespace there's a class names
FieldNameLookup which is used by SqlDataReader.GetOrdinal() to lookup the
field names, and it also contains an IndexOfName() method, which returns -1
if the field name is unknown. I can't understand why SqlDataReader doesn't
also expose a method like this (since it's easy and possible to do it). Or
am I missing something?
Regards,
Andrei