what's wrong with this IF / ELSE statement? ASP/VBScript - Macromedia Dreamweaver

This is a discussion on what's wrong with this IF / ELSE statement? ASP/VBScript - Macromedia Dreamweaver ; Hi, I'm trying to display a section, within an ASP page, where the customer logged in is the same as the customer who placed the order, identified by their "customerID". <%IF (rsUser.Fields.Item("customerID").Value) = "(rsOrderDetails.Fields.Item("& customerID &").Value)" Then%> Text etc... <%Else%> ...

+ Reply to Thread
Results 1 to 9 of 9

what's wrong with this IF / ELSE statement? ASP/VBScript

  1. Default what's wrong with this IF / ELSE statement? ASP/VBScript

    Hi,

    I'm trying to display a section, within an ASP page, where the customer
    logged in is the same as the customer who placed the order, identified by
    their "customerID".

    <%IF (rsUser.Fields.Item("customerID").Value) =
    "(rsOrderDetails.Fields.Item("& customerID &").Value)" Then%>
    Text etc...
    <%Else%>
    Other text etc...
    <%End IF%>

    The customerID in both database tables is a "bigint" type, but when I try
    the above, I get: "Type Mismatch"?

    I've tried this:

    <%IF (rsUser.Fields.Item("customerID").Value) =
    (rsOrderDetails.Fields.Item("& customerID &").Value) Then%>
    Text etc...
    <%Else%>
    Other text etc...
    <%End IF%>

    But this also produces a Type Mismatch error.

    Anything glaringly obviously wrong with this? Much appreciated.

    Nath.



  2. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    tradmusic.com wrote:
    > Hi,
    >
    > I'm trying to display a section, within an ASP page, where the customer
    > logged in is the same as the customer who placed the order, identified by
    > their "customerID".
    >
    > <%IF (rsUser.Fields.Item("customerID").Value) =
    > "(rsOrderDetails.Fields.Item("& customerID &").Value)" Then%>
    > Text etc...
    > <%Else%>
    > Other text etc...
    > <%End IF%>
    >
    > The customerID in both database tables is a "bigint" type, but when I try
    > the above, I get: "Type Mismatch"?
    >
    > I've tried this:
    >
    > <%IF (rsUser.Fields.Item("customerID").Value) =
    > (rsOrderDetails.Fields.Item("& customerID &").Value) Then%>
    > Text etc...
    > <%Else%>
    > Other text etc...
    > <%End IF%>
    >
    > But this also produces a Type Mismatch error.
    >
    > Anything glaringly obviously wrong with this? Much appreciated.


    Whats with this? (rsOrderDetails.Fields.Item("& customerID &").Value)
    Why are there ampersands in there?

    It should be just this: (rsOrderDetails.Fields.Item("customerID").Value)

    Steve

  3. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    Sorry Steve,

    I forgot to remove those from the last example. It should have read:

    <%IF (rsUser.Fields.Item("customerID").Value) =
    (rsOrderDetails.Fields.Item("customerID").Value) Then%>
    Text etc...
    <%Else%>
    Other text etc...
    <%End IF%>

    ....which still doesn't work. )

    Type Mismatch, yet both fields are bigint.

    Any idea's where the problem is? Much appreciated.
    Nath.


    "Dooza" <doozadooza@gmail.com> wrote in message
    news:ftvjd5$cqa$2@forums.macromedia.com...
    > tradmusic.com wrote:
    >> Hi,
    >>
    >> I'm trying to display a section, within an ASP page, where the customer
    >> logged in is the same as the customer who placed the order, identified by
    >> their "customerID".
    >>
    >> <%IF (rsUser.Fields.Item("customerID").Value) =
    >> "(rsOrderDetails.Fields.Item("& customerID &").Value)" Then%>
    >> Text etc...
    >> <%Else%>
    >> Other text etc...
    >> <%End IF%>
    >>
    >> The customerID in both database tables is a "bigint" type, but when I try
    >> the above, I get: "Type Mismatch"?
    >>
    >> I've tried this:
    >>
    >> <%IF (rsUser.Fields.Item("customerID").Value) =
    >> (rsOrderDetails.Fields.Item("& customerID &").Value) Then%>
    >> Text etc...
    >> <%Else%>
    >> Other text etc...
    >> <%End IF%>
    >>
    >> But this also produces a Type Mismatch error.
    >>
    >> Anything glaringly obviously wrong with this? Much appreciated.

    >
    > Whats with this? (rsOrderDetails.Fields.Item("& customerID &").Value) Why
    > are there ampersands in there?
    >
    > It should be just this: (rsOrderDetails.Fields.Item("customerID").Value)
    >
    > Steve




  4. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    Ok, it looks like you will need to convert them to the same format, even
    if ASP doesn't think they are the same.

    <%IF cstr(rsUser.Fields.Item("customerID").Value) =
    cstr(rsOrderDetails.Fields.Item("customerID").Value) Then%>
    Text etc...
    <%Else%>
    Other text etc...
    <%End IF%>

    That converts both to a string, which should evaluate against each other.

    See if that helps.

    Steve

    tradmusic.com wrote:
    > Sorry Steve,
    >
    > I forgot to remove those from the last example. It should have read:
    >
    > <%IF (rsUser.Fields.Item("customerID").Value) =
    > (rsOrderDetails.Fields.Item("customerID").Value) Then%>
    > Text etc...
    > <%Else%>
    > Other text etc...
    > <%End IF%>
    >
    > ....which still doesn't work. )
    >
    > Type Mismatch, yet both fields are bigint.
    >
    > Any idea's where the problem is? Much appreciated.
    > Nath.
    >
    >
    > "Dooza" <doozadooza@gmail.com> wrote in message
    > news:ftvjd5$cqa$2@forums.macromedia.com...
    >> tradmusic.com wrote:
    >>> Hi,
    >>>
    >>> I'm trying to display a section, within an ASP page, where the customer
    >>> logged in is the same as the customer who placed the order, identified by
    >>> their "customerID".
    >>>
    >>> <%IF (rsUser.Fields.Item("customerID").Value) =
    >>> "(rsOrderDetails.Fields.Item("& customerID &").Value)" Then%>
    >>> Text etc...
    >>> <%Else%>
    >>> Other text etc...
    >>> <%End IF%>
    >>>
    >>> The customerID in both database tables is a "bigint" type, but when I try
    >>> the above, I get: "Type Mismatch"?
    >>>
    >>> I've tried this:
    >>>
    >>> <%IF (rsUser.Fields.Item("customerID").Value) =
    >>> (rsOrderDetails.Fields.Item("& customerID &").Value) Then%>
    >>> Text etc...
    >>> <%Else%>
    >>> Other text etc...
    >>> <%End IF%>
    >>>
    >>> But this also produces a Type Mismatch error.
    >>>
    >>> Anything glaringly obviously wrong with this? Much appreciated.

    >> Whats with this? (rsOrderDetails.Fields.Item("& customerID &").Value) Why
    >> are there ampersands in there?
    >>
    >> It should be just this: (rsOrderDetails.Fields.Item("customerID").Value)
    >>
    >> Steve

    >
    >


  5. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    > Type Mismatch, yet both fields are bigint.

    Are they required fields? If not, you might have some null values in there.

    Dooza's solution should work.

    Otherwise, you can use an ISNULL function in your db query.

    -Darrel



  6. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    Thanks Dooza, that's sorted it.
    Why does ASP not recognise that they are the same format?

    Appreciate the help.
    Regards
    Nath.

    "Dooza" <doozadooza@gmail.com> wrote in message
    news:ftvraf$la5$1@forums.macromedia.com...
    > Ok, it looks like you will need to convert them to the same format, even
    > if ASP doesn't think they are the same.
    >
    > <%IF cstr(rsUser.Fields.Item("customerID").Value) =
    > cstr(rsOrderDetails.Fields.Item("customerID").Value) Then%>
    > Text etc...
    > <%Else%>
    > Other text etc...
    > <%End IF%>
    >
    > That converts both to a string, which should evaluate against each other.
    >
    > See if that helps.
    >
    > Steve
    >
    > tradmusic.com wrote:
    >> Sorry Steve,
    >>
    >> I forgot to remove those from the last example. It should have read:
    >>
    >> <%IF (rsUser.Fields.Item("customerID").Value) =
    >> (rsOrderDetails.Fields.Item("customerID").Value) Then%>
    >> Text etc...
    >> <%Else%>
    >> Other text etc...
    >> <%End IF%>
    >>
    >> ....which still doesn't work. )
    >>
    >> Type Mismatch, yet both fields are bigint.
    >>
    >> Any idea's where the problem is? Much appreciated.
    >> Nath.
    >>
    >>
    >> "Dooza" <doozadooza@gmail.com> wrote in message
    >> news:ftvjd5$cqa$2@forums.macromedia.com...
    >>> tradmusic.com wrote:
    >>>> Hi,
    >>>>
    >>>> I'm trying to display a section, within an ASP page, where the customer
    >>>> logged in is the same as the customer who placed the order, identified
    >>>> by their "customerID".
    >>>>
    >>>> <%IF (rsUser.Fields.Item("customerID").Value) =
    >>>> "(rsOrderDetails.Fields.Item("& customerID &").Value)" Then%>
    >>>> Text etc...
    >>>> <%Else%>
    >>>> Other text etc...
    >>>> <%End IF%>
    >>>>
    >>>> The customerID in both database tables is a "bigint" type, but when I
    >>>> try the above, I get: "Type Mismatch"?
    >>>>
    >>>> I've tried this:
    >>>>
    >>>> <%IF (rsUser.Fields.Item("customerID").Value) =
    >>>> (rsOrderDetails.Fields.Item("& customerID &").Value) Then%>
    >>>> Text etc...
    >>>> <%Else%>
    >>>> Other text etc...
    >>>> <%End IF%>
    >>>>
    >>>> But this also produces a Type Mismatch error.
    >>>>
    >>>> Anything glaringly obviously wrong with this? Much appreciated.
    >>> Whats with this? (rsOrderDetails.Fields.Item("& customerID &").Value)
    >>> Why are there ampersands in there?
    >>>
    >>> It should be just this: (rsOrderDetails.Fields.Item("customerID").Value)
    >>>
    >>> Steve

    >>



  7. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    Yes, they are both required fields and Dooza's solution has resolved it.
    Thanks for the advice.

    Regards
    Nath.

    "darrel" <notreal@nowhere.com> wrote in message
    news:ftvs65$mdb$1@forums.macromedia.com...
    >> Type Mismatch, yet both fields are bigint.

    >
    > Are they required fields? If not, you might have some null values in
    > there.
    >
    > Dooza's solution should work.
    >
    > Otherwise, you can use an ISNULL function in your db query.
    >
    > -Darrel
    >
    >




  8. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    tradmusic.com wrote:
    > Thanks Dooza, that's sorted it.
    > Why does ASP not recognise that they are the same format?


    Thats a very good question...I just don't have the answer. What I have
    observed over the years from the code that the extensions sometimes
    write, is that many recordset values need to converted to string before
    being evaluated in an expression. Maybe one of the more advanced ASP
    coders around might be able to answer this?

    Steve

  9. Default Re: what's wrong with this IF / ELSE statement? ASP/VBScript

    I am not an advanced VBScript guy, but from some other links on the net, I understood that VBScript doesn't understand bigint.

+ Reply to Thread