Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

problem with null

Hi guys. I'm trying to write a little exe that pulls info from a sql server 2000 database and turns it into a price list. Everything works fine except when I get to something that has a null value. When I try and use a field that has a null value it gives me an error that says "Cannot get value because it is DBNull." This is what the code that throws the error looks like:
_____________________________________________________________________
Public Property item_desc_2 As String
Get
Try
Return CType(Me(Me.tableIMITMIDX_SQL.item_desc_2Column), String)
Catch e As InvalidCastException
Throw New StrongTypingException("Cannot get value
because it is DBNull.", e)
End Try
End Get
Set
Me(Me.tableIMITMIDX_SQL.item_desc_2Column) = value
End Set
End Property

____________________________________________________________________

I've tried different things out to try and catch the error, but just can't seem to get it. And I'm not used to vb.net, I'm a lot more familiar with php and java. I've tried to find a similar problem online but just can't seem to find one. Any ideas at all would be appreciated.

Comments

  • Termc1224Termc1224 Member Posts: 84
    : Hi guys. I'm trying to write a little exe that pulls info from a sql server 2000 database and turns it into a price list. Everything works fine except when I get to something that has a null value. When I try and use a field that has a null value it gives me an error that says "Cannot get value because it is DBNull." This is what the code that throws the error looks like:
    : _____________________________________________________________________
    : Public Property item_desc_2 As String
    : Get
    : Try
    : Return CType(Me(Me.tableIMITMIDX_SQL.item_desc_2Column), String)
    : Catch e As InvalidCastException
    : Throw New StrongTypingException("Cannot get value
    : because it is DBNull.", e)
    : End Try
    : End Get
    : Set
    : Me(Me.tableIMITMIDX_SQL.item_desc_2Column) = value
    : End Set
    : End Property
    :
    : ____________________________________________________________________
    :
    : I've tried different things out to try and catch the error, but just can't seem to get it. And I'm not used to vb.net, I'm a lot more familiar with php and java. I've tried to find a similar problem online but just can't seem to find one. Any ideas at all would be appreciated.
    :

    try putting this after the event name
    on error resume next
    I'm the best there is,
    the best there was,
    and the best there ever will be.
    hahahahaha lolz :)

  • Commander123Commander123 Member Posts: 1
    : Hi guys. I'm trying to write a little exe that pulls info from a sql server 2000 database and turns it into a price list. Everything works fine except when I get to something that has a null value. When I try and use a field that has a null value it gives me an error that says "Cannot get value because it is DBNull." This is what the code that throws the error looks like:
    : _____________________________________________________________________
    : Public Property item_desc_2 As String
    : Get
    : Try
    : Return CType(Me(Me.tableIMITMIDX_SQL.item_desc_2Column), String)
    : Catch e As InvalidCastException
    : Throw New StrongTypingException("Cannot get value
    : because it is DBNull.", e)
    : End Try
    : End Get
    : Set
    : Me(Me.tableIMITMIDX_SQL.item_desc_2Column) = value
    : End Set
    : End Property
    :
    : ____________________________________________________________________
    :
    : I've tried different things out to try and catch the error, but just can't seem to get it. And I'm not used to vb.net, I'm a lot more familiar with php and java. I've tried to find a similar problem online but just can't seem to find one. Any ideas at all would be appreciated.
    :


    just try these &""
    it can handle a null values
Sign In or Register to comment.