If in a table, some columns occasionally contain null values, then while trying to retrieve the values, the following error is shown:

Conversion from type ‘DBNull’ to type ‘String’ is not valid.

To solve this problem, we can check if the Datareader has a null value for the column, and if yes, then just getting the TextBox to show an empty string.

If DBNull.Value.Equals(dataReader1(“Column_Name”)) Then

TextBox.Text = “”


TextBox.Text = dataReader1(“Column_Name”)

End If