Advertisement

07.12.2007 at 01:26AM PDT, ID: 22691048
[x]
Attachment Details

VB.Net SQLDataReader IsDBNull function column position

Asked by ccravenbartle in Visual Studio .NET 2005

Tags: isdbnull, sqldatareader

I am using an SQLDataReader in VB.Net.  I am using the IsDBNull function to check if a date field is not null before populating a private member date variable:
 If Not reader.IsDBNull(9) Then m_accountclosed = reader("AccountClosed")
However, I do not want to use the column position index, in this case (9), as I may need to insert new columns to the table and I do not want to have to keep editing the code to change the column position index number.  Is there a way of indicating the column in the IsDBNull function by using the field name?  I tried:
If Not reader.IsDBNull("AccountClosed")
but that did not work.


          Start Free Trial
 
Loading Advertisement...
 
[+][-]07.12.2007 at 05:22AM PDT, ID: 19470843

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Studio .NET 2005
Tags: isdbnull, sqldatareader
Sign Up Now!
Solution Provided By: TSmooth
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32