Recordset Display Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maria Kovacs

    Recordset Display Question

    I am a begginner with ASP.
    Can someone help me fix this?
    I am trying to display order tracking links from a DB table.

    If there is a tracking link listed for a company it should display
    "Track Now" as a hyperlink. If there is no order tracking link listed
    it displays: "No Address".

    The link displays fine if I just use:
    <a href="<%=rs.Fie lds.Item("Order _Tracking").Val ue%>"><%=rs.Fie lds.Item("Order _Tracking").Val ue%></a>
    but I don't want that because some of the links are very long.

    PROBLEM: I have about 50 companies to display about 30 of them has a
    package tracking link provided. All displays however as "No Address".
    Here is the code I would like to use. Can someone put me in the right
    direction:
    <%
    If VIPPtracking = "" then
    Response.Write( "<a href=""" &
    rs.Fields.Item( "Order_Tracking ").Value & """>Track Now</a>")

    else
    Response.write( "No Address")
    End If
    %>
  • Ray at

    #2
    Re: Recordset Display Question

    Where are you giving the VIPTracking variable its value?

    Ray at work


    "Maria Kovacs" <mariakovacs@ly cos.com> wrote in message
    news:6f76be22.0 401270845.5c5b8 13b@posting.goo gle.com...
    [color=blue]
    >
    > PROBLEM: I have about 50 companies to display about 30 of them has a
    > package tracking link provided. All displays however as "No Address".
    > Here is the code I would like to use. Can someone put me in the right
    > direction:
    > <%
    > If VIPPtracking = "" then
    > Response.Write( "<a href=""" &
    > rs.Fields.Item( "Order_Tracking ").Value & """>Track Now</a>")
    >
    > else
    > Response.write( "No Address")
    > End If
    > %>[/color]


    Comment

    • Maria Kovacs

      #3
      Re: Recordset Display Question

      > Where are you giving the VIPTracking variable its value?[color=blue]
      >
      > Ray at work[/color]

      dim VIPPtrack
      dim grid_VIPPuserli nks_sql
      ....
      sub request_grid_VI PPuserlinks
      VIPPtrack = request("Order_ Tracking")
      ....
      sub validate_grid_V IPPuserlinks
      VIPPtrack = trim(request("O rder_Tracking") )
      ....
      sub db_select_grid_ VIPPUserLinks
      grid_VIPPUserLi nks_sql = "SELECT * FROM VIPP left join
      VIPPUserLinks.. ..
      ....
      user_id = session("user_i d")
      if user_id <> "" then
      db_select_grid_ VIPPUserLinks
      end if
      ....

      <%
      do while not rs.EOF
      on error resume next
      ....
      VIPPtrack = rs("Order_Track ing")
      on error goto 0
      %>
      <table>With Order tracking code above and other related info like fax,
      phone #</table>

      Comment

      • Ray at

        #4
        Re: Recordset Display Question

        You're testing if VIPTrack="" and if it does = "", then it should write your
        link. Considering that you're assigning a value to VIPTrack in three
        different places from request.? collections and from a recordset, chances
        are the value is never or rarely "". Response.Write the value to see what
        it is. Or just use a test if/then like so:

        VIPTrack = Request.FORM("O rder_Tracking")
        If VIPTrack = "" Then
        Response.Write "VIPTrack is not an empty string. It is: " & VIPTrack
        Else
        Response.Write "VIPTrack is an empty string.
        End If

        Also, please see here. http://www.aspfaq.com/show.asp?id=2111

        Ray at home

        "Maria Kovacs" <mariakovacs@ly cos.com> wrote in message
        news:6f76be22.0 401271409.247b8 31a@posting.goo gle.com...[color=blue][color=green]
        > > Where are you giving the VIPTracking variable its value?
        > >
        > > Ray at work[/color]
        >
        > dim VIPPtrack
        > dim grid_VIPPuserli nks_sql
        > ...
        > sub request_grid_VI PPuserlinks
        > VIPPtrack = request("Order_ Tracking")
        > ...
        > sub validate_grid_V IPPuserlinks
        > VIPPtrack = trim(request("O rder_Tracking") )
        > ...
        > sub db_select_grid_ VIPPUserLinks
        > grid_VIPPUserLi nks_sql = "SELECT * FROM VIPP left join
        > VIPPUserLinks.. ..
        > ...
        > user_id = session("user_i d")
        > if user_id <> "" then
        > db_select_grid_ VIPPUserLinks
        > end if
        > ...
        >
        > <%
        > do while not rs.EOF
        > on error resume next
        > ...
        > VIPPtrack = rs("Order_Track ing")
        > on error goto 0
        > %>
        > <table>With Order tracking code above and other related info like fax,
        > phone #</table>[/color]


        Comment

        • Maria Kovacs

          #5
          Re: Recordset Display Question

          I corrected all the Request.Form("i tem") collection names, and tried
          the code you gave me.

          Right now I am getting only: "VIPPtrack is not an empty string. It is:
          "
          no matter if there is a link or not. I never get "VIPTrack is an empty
          string."

          Comment

          • Ray at

            #6
            Re: Recordset Display Question

            Do you expect it to be an empty string ever? What kind of form element is
            it?

            Ray at home


            "Maria Kovacs" <mariakovacs@ly cos.com> wrote in message
            news:6f76be22.0 401280646.a1e4d 8c@posting.goog le.com...[color=blue]
            > I corrected all the Request.Form("i tem") collection names, and tried
            > the code you gave me.
            >
            > Right now I am getting only: "VIPPtrack is not an empty string. It is:
            > "
            > no matter if there is a link or not. I never get "VIPTrack is an empty
            > string."[/color]


            Comment

            • Maria Kovacs

              #7
              Re: Recordset Display Question

              If I write:
              <%
              If VIPPtracking = "" then
              Response.Write( "No Address")

              else
              Response.write( "<a href=""" & rs.Fields.Item( "Order_Tracking ").Value
              & """>Track Now</a>")

              End If
              %>

              Then I get "No Address" everywhere.
              ---
              If I reverse it:
              <%
              If VIPPtracking = "" then
              Response.Write( "No Address")

              else
              Response.write( "<a href=""" &
              rs.Fields.Item( "Order_Tracking ").Value & """>Track Now</a>")

              End If
              %>

              Then I get "Track Now" with the link of the portal's index page where
              there is no OrderTracking link provided,
              and
              get "Track Now" and the corresponding company's tracking link, where
              listed.

              I don't understand, in the case of NO tracking link listed, why would
              it use the portal's index page as a link?

              Comment

              • Ray at

                #8
                Re: Recordset Display Question

                This problem has nothing to do with writing links, portals, or recordsets or
                anything like that. It is all about the value of VIPTracking.

                Ray at home

                "Maria Kovacs" <mariakovacs@ly cos.com> wrote in message
                news:6f76be22.0 401280707.6071d 3d0@posting.goo gle.com...[color=blue]
                > If I write:
                > <%
                > If VIPPtracking = "" then
                > Response.Write( "No Address")
                >
                > else
                > Response.write( "<a href=""" & rs.Fields.Item( "Order_Tracking ").Value
                > & """>Track Now</a>")
                >
                > End If
                > %>
                >
                > Then I get "No Address" everywhere.
                > ---
                > If I reverse it:
                > <%
                > If VIPPtracking = "" then
                > Response.Write( "No Address")
                >
                > else
                > Response.write( "<a href=""" &
                > rs.Fields.Item( "Order_Tracking ").Value & """>Track Now</a>")
                >
                > End If
                > %>
                >
                > Then I get "Track Now" with the link of the portal's index page where
                > there is no OrderTracking link provided,
                > and
                > get "Track Now" and the corresponding company's tracking link, where
                > listed.
                >
                > I don't understand, in the case of NO tracking link listed, why would
                > it use the portal's index page as a link?[/color]


                Comment

                • Bob Lehmann

                  #9
                  Re: Recordset Display Question

                  Have you tried Response.Write ( Request.Form("O rder_Tracking") ) with no logic around it, as Ray suggested?

                  If it does have a value, then try this.....

                  When I've run into this problem, this seems to do the trick....
                  <%
                  If Not VIPPtracking = "" then

                  Response.write( "<a href=""" & rs.Fields.Item( "Order_Tracking ").Value & """>Track Now</a>")

                  else
                  Response.Write( "No Address")

                  End If
                  %>

                  Bob Lehmann

                  "Maria Kovacs" <mariakovacs@ly cos.com> wrote in message news:6f76be22.0 401280707.6071d 3d0@posting.goo gle.com...[color=blue]
                  > If I write:
                  > <%
                  > If VIPPtracking = "" then
                  > Response.Write( "No Address")
                  >
                  > else
                  > Response.write( "<a href=""" & rs.Fields.Item( "Order_Tracking ").Value
                  > & """>Track Now</a>")
                  >
                  > End If
                  > %>
                  >
                  > Then I get "No Address" everywhere.
                  > ---
                  > If I reverse it:
                  > <%
                  > If VIPPtracking = "" then
                  > Response.Write( "No Address")
                  >
                  > else
                  > Response.write( "<a href=""" &
                  > rs.Fields.Item( "Order_Tracking ").Value & """>Track Now</a>")
                  >
                  > End If
                  > %>
                  >
                  > Then I get "Track Now" with the link of the portal's index page where
                  > there is no OrderTracking link provided,
                  > and
                  > get "Track Now" and the corresponding company's tracking link, where
                  > listed.
                  >
                  > I don't understand, in the case of NO tracking link listed, why would
                  > it use the portal's index page as a link?[/color]

                  Comment

                  Working...