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
If  Not IsDBNull(objDataReader.GetString(12)) Then
   ...
End If
If  Not IsDBNull(objDataReader.GetString(12)) Then
   ...
End If

Tried this. Still get same error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.