0

I can't get past this error in my loop through the data reader specifically dr(12). I tried adding .To String but that doesn't seem to work either. Can someone help me with what need to do so it can read even if there is a Null value. My code is below:

While objDataReader.Read()
                            'Set up DataRow object
                            Dim dr As DataRow = DataReaderTable.NewRow

                            With dr
                                dr(0) = objDataReader.GetSqlInt32(0)    'IndividualID
                                dr(1) = objDataReader.GetString(1)      'First Name
                                dr(2) = objDataReader.GetString(2)      'Last Name
                                dr(3) = objDataReader.GetString(3)      'Email Address
                                dr(4) = objDataReader.GetString(4)      'Address 1
                                dr(5) = objDataReader.GetString(5)      'City
                                dr(6) = objDataReader.GetString(6)      'State
                                dr(7) = objDataReader.GetString(7)      'Post Code
                                dr(8) = objDataReader.GetString(8)      'Phone Number
                                dr(9) = objDataReader.GetString(9)      'Session Date
                                dr(10) = objDataReader.GetString(10)    'UpdateBy
                                dr(11) = objDataReader.GetSqlInt32(11)    'ProductID
                                dr(12) = objDataReader.GetString(12).ToString 'User7

                            End With
                            'Add row to existing dataTable
                            DataReaderTable.Rows.Add(dr)
                        End While
2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by mldardy
0
If  Not IsDBNull(objDataReader.GetString(12)) Then
   ...
End If

Tried this. Still get same error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.