check for null

Discussion in 'ASP .Net' started by =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Sep 14, 2005.

  1. Why will this not work?
    it comes back with an error saying it can't work because the value is null
    this is a dataset value retreaved from db and it is null.
    call to check for null
    Me.txtExtra1.Text = Me.MNS(.usrExtra1)

    function to return a default value:
    Public Function MNS(ByVal s As Object) As String
    If IsDBNull(s) Then
    Return String.Empty
    Else
    Return CType(s, String)
    End If
    End Function
    thnaks
    kes
    --
    thanks (as always)
    some day i''m gona pay this forum back for all the help i''m getting
    kes
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Sep 14, 2005
    #1
    1. Advertising

  2. just out of curiosity...
    Try a compare against System.DBNull.Value

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "WebBuilder451" wrote:

    > Why will this not work?
    > it comes back with an error saying it can't work because the value is null
    > this is a dataset value retreaved from db and it is null.
    > call to check for null
    > Me.txtExtra1.Text = Me.MNS(.usrExtra1)
    >
    > function to return a default value:
    > Public Function MNS(ByVal s As Object) As String
    > If IsDBNull(s) Then
    > Return String.Empty
    > Else
    > Return CType(s, String)
    > End If
    > End Function
    > thnaks
    > kes
    > --
    > thanks (as always)
    > some day i''m gona pay this forum back for all the help i''m getting
    > kes
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Sep 14, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kivak Wolf
    Replies:
    2
    Views:
    10,053
    Kivak Wolf
    Jun 28, 2005
  2. vizlab
    Replies:
    3
    Views:
    4,163
    Michael Bar-Sinai
    Oct 17, 2007
  3. Replies:
    5
    Views:
    26,433
    Mike Schilling
    Mar 29, 2006
  4. G Fernandes
    Replies:
    9
    Views:
    564
    DHOLLINGSWORTH2
    Feb 27, 2005
  5. Mike
    Replies:
    12
    Views:
    693
    Daniel Pitts
    Sep 26, 2008
Loading...

Share This Page