8 Jun
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 = “”
Else
TextBox.Text = dataReader1(“Column_Name”)
End If

| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Aug | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||

2 Responses for "How To Show A Null Value From Database In TextBox In VB.NET"
I m loading data in my VB.NET software from excel file. the Excel sheet i m using have some data like “name” or “crop name”. But when i load the data and want that name to be displayed in a textbox then it shows me the error “Conversion from type ‘DBNull’ to type ‘String’ is not valid.” why is it so?? i want that name in text box but unable to do so.
please help me..
I am trying to do a query that returns information entered in a textbox. I am using Access 2007 and visual basic code. Can anyone help me?
Leave a comment
Your email will never be published/shared.