IsDBNull

Southern_Gentleman
Southern_Gentleman used Ask the Experts™
on
This is probably a simple question but i'm having trouble with Null Values from a Querystring. This data is being pulled from a Dataset.
Conversion from type 'DBNull' to type 'Date' is not valid.

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not String.IsNullOrEmpty(Request.QueryString("OrderID"))) Then
            Me.lblOrderId.Text = Request.QueryString("OrderID")
        End If
 Dim order As New artemailformdata.OrdersDataTable()
        Dim orderAdapater As New artemailformdataTableAdapters.OrdersTableAdapter()
        order = orderAdapater.GetData(Convert.ToInt32(Request.QueryString("OrderId")))
  If order.Count <> 0 Then
lblInHands.Text = order.Item(0).InHands
            lblFADC.Text = order.Item(0).FrontArtDC
End If
End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Software Developer
Commented:
I don't see anywhere in the code you provided where you're converting a value to type 'Date'

This would indicate that the actual exception is being thrown somewhere in a method that you're calling from this code.
Top Expert 2016
Commented:
one should always test for null (dbNull) before trying do do any conversion.

Author

Commented:
Thanks guys, was able to figure it out.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial