Results 1 to 7 of 7

Thread: [RESOLVED] How to check DBNull Value?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2009
    Posts
    37

    Resolved [RESOLVED] How to check DBNull Value?

    Hi,

    I have a problem with verifying dbnull value. Actually I don't know the syntax.
    Here is the code.
    Code:
                If Not IsDBNull(Me.DeliveryReviewDataSet.Delivery(Me.CustomerIDListBox.SelectedIndex).Signature) Then
    "Signature" is the image field (binary data).

    Any help will be appreciated.
    Thanks
    zhtway

  2. #2

    Thread Starter
    Member
    Join Date
    Apr 2009
    Posts
    37

    Re: How to check DBNull Value?

    Hi,
    I post it in the wrong place. don't know how to move to VB forum
    zhtway

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to check DBNull Value?

    Quote Originally Posted by zhtway1 View Post
    I post it in the wrong place. don't know how to move to VB forum
    But I do...Moved From The CodeBank

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to check DBNull Value?

    There are various ways to check for NULL and the best way depends the circumstances. In your case, you're using a typed DataSet so it specifically provides methods for you to set a field to NULL and to determine if a field is NULL. First up, if you want the row selected in the ListBox:
    vb.net Code:
    1. Dim row As DeliveryDataRow = DirectCast(Me.DeliveryBindingSource.Current, DeliveryDataRow)
    2.  
    3. If row.IsSignatureNull() Then
    4.     'Signature is NULL.
    5. End If
    The converse operation uses the SetSignatureNull method.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2009
    Posts
    37

    Re: How to check DBNull Value?

    Hi,

    Thanks for your reply.
    I have to modify code from your reply as it showed up with errors.
    Pls correct me if I am wrong.
    Error is "Error:unable to cast object of type 'System.data.datarowview' to type 'DeliveryRow'.
    Code:
                Dim row As DeliveryReviewDataSet.DeliveryRow = DirectCast(Me.DeliveryBindingSource.Current, DeliveryReviewDataSet.DeliveryRow)
                If row.IsSignatureNull() Then
                    MsgBox("it is null")
                End If
    Thanks again,
    zhtway

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to check DBNull Value?

    Ah, sorry. That's the risk when typing straight into the forum rather than an IDE. It should actually be:
    vb.net Code:
    1. Dim row As DeliveryReviewDataSet.DeliveryRow = DirectCast(DirectCast(Me.DeliveryBindingSource.Current, DataRowView).Row, DeliveryReviewDataSet.DeliveryRow)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2009
    Posts
    37

    Re: [RESOLVED] How to check DBNull Value?

    Hi,

    Thanks for your help!
    It solved.

    rgds,
    zhtway

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