If then and null or empty value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vertigo262
    New Member
    • Jul 2007
    • 62

    If then and null or empty value

    Is there a better way of doing this.

    I've been doing it this way for years, but I'm always having problems.

    In this case the logic doesn't seem to work.

    error

    Input string was not in a correct format.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.FormatEx ception: Input string was not in a correct format.

    Source Error:

    Line 142:
    Line 143: If Not IsNothing(UserI D) Or Not IsDBNull(UserID ) Or Not UserID = "" Then
    Line 144: Dal.UpdateCompa nyWebsiteViews( UserID)
    Line 145: End If
    Line 146: If Not IsNothing(Websi teURL) Or Not IsDBNull(Websit eURL) Then


    The db field is either empty or dbnull.

    so why is doing it this way always so glitchy, and anyone know what's wrong, or a better way of doing it.

    Code:
    If Not IsNothing(UserID) Or Not IsDBNull(UserID) Or Not UserID = "" Then
                Dal.UpdateCompanyWebsiteViews(UserID)
            End If
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    There is a String.IsNullOr Empty method that you can use to check if a string is null or empty...


    -Frinny

    Comment

    Working...