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("AccountCl
osed")
but that did not work.
Start Free Trial