Results 1 to 2 of 2

Thread: Problem with datarow

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Problem with datarow

    Ok, Im iterating through a datatable, and I have a problem:

    For Each dr In dt.Rows
    Try
    litShipNo.Text = CStr(dr("SHIPMENT_ID"))

    etc etc...

    as you can see Im casting every value to string because I want to show them as literate text. But I ahve a problem with when the column is of value DBNull, then I get an exception, and I am not sure how to handle it... can anyone give a suggestion?


    kind regards
    Henrik

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I havent used VB.Net, but this works in VB6:

    litShipNo.Text = CStr(dr("SHIPMENT_ID") & "")

    or:
    VB Code:
    1. If IsNull(dr("SHIPMENT_ID")) Then
    2.   litShipNo.Text = "Null"
    3. Else  
    4.   litShipNo.Text = CStr(dr("SHIPMENT_ID"))
    5. End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width