VB 2010 with MS Access 2010 Error Conversion from type 'DBNull' to type 'String' is not valid.

VB .NET Error Conversion from type 'DBNull' to type 'String' is not valid.

vb.net Error Conversion from type 'DBNull' to type 'String' is not valid.
VB .NET Conversion from type 'DBNull' to type 'String' is not valid.

Error :

Conversion from type 'DBNull' to type 'String' is not valid.

Cause :

Trying to Fetch Data From empty database table field, where database table field doesn't have any data 'null'.

Solution :

'adonetaccess2003.blogspot.com
'This method uses connected mode
If IsDBNull(DataReader!Field_Name) Then
TextBox1.Text = ("Anything you wish for now")
Exit Sub
End If
'Another method using disconnected mode 'DataSet'
TextBox1.Text = DataTable.Rows(0)("Field_Name").ToString()
'Another method from Database Table.
Dim SqlStr As String = "select IsNull(Field_Name,'') as Any_Name from Table_Name"
view raw gistfile1.txt hosted with ❤ by GitHub

According to StackOverFlow, you may also try this solution instead, which also work fine but you need to determine at which end your problem exists "The application" or "The Database table", because you can workaround your this problem "DBNull" from Database table or from Visual Basic .Net.


Here are some online Visual Basic lessons and courses :

Popular posts from this blog

VB .NET DropBox Api Source Code Example

VB .NET Google Drive Api Source Code Example

VB.NET Access 2007 Hierarchical TreeView

VB.NET How to properly close a windows application Form

DAO in VB .NET MS ACCESS Database

Solution - There is already an open DataReader associated with this Command which must be closed first.