[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
Re: How to check DBNull Value?
Hi,
I post it in the wrong place. don't know how to move to VB forum
zhtway
Re: How to check DBNull Value?
Quote:
Originally Posted by
zhtway1
I post it in the wrong place. don't know how to move to VB forum
But I do...Moved From The CodeBank :)
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:
Dim row As DeliveryDataRow = DirectCast(Me.DeliveryBindingSource.Current, DeliveryDataRow)
If row.IsSignatureNull() Then
'Signature is NULL.
End If
The converse operation uses the SetSignatureNull method.
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
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:
Dim row As DeliveryReviewDataSet.DeliveryRow = DirectCast(DirectCast(Me.DeliveryBindingSource.Current, DataRowView).Row, DeliveryReviewDataSet.DeliveryRow)
Re: [RESOLVED] How to check DBNull Value?
Hi,
Thanks for your help!
It solved.
rgds,
zhtway