ManageMobility
asked on
How do I test to see if an index is within a range (or exists) without throwing an error?
I am pulling fields that may or may not be contained in the SqlDataReader called ReaderOrderInfo.
How can I test the datareader if it contains this index before attempting to pull it (which throws an error)?
The site is coded in VB .NET
Thanks!
How can I test the datareader if it contains this index before attempting to pull it (which throws an error)?
The site is coded in VB .NET
Thanks!
If Not ReaderOrderInfo(oiNode.FieldName) Is Nothing Then
oiNode.Value = ReaderOrderInfo(oiNode.FieldName)
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is no other way, unless you want to catch an exception, which is no recommended.
ASKER
That's what I'm afraid of. I may have to just take on the extra loop.
and btw, what exactly do you think data provider would do if there is a method like
if (dr.Columnexist(columnname ))
{
}
it ould neeed to loop through all column, right? The code would just look better, abstraction in action. :)
if (dr.Columnexist(columnname
{
}
it ould neeed to loop through all column, right? The code would just look better, abstraction in action. :)
ASKER
Good point :)
ASKER