VB.Net, ADO.Net: How to handle null value in a database

Sometimes your program might crashes because of null value in the database. The following shows the sample code to check whether a value is a null.

Example:
If ds.Tables(0).Rows(cboProd.SelectedIndex).Item("price") _ Is DBNull.Value Then
   lblPrice.Text = "Not Available"
Else
   lblPrice.Text = _
     ds.Tables(0).Rows(cboProd.SelectedIndex).Item("price")
End If

Keywords:
VB.Net, ADO.Net: How to handle null value in a database
VB.Net Programming, VB.Net Code, VB.Net Help
Exclude Keywords: Finance Investment, Stock Market

Post a Comment

0 Comments