Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 4th, 2006, 11:09 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to display one field as a hyperlink?

I have some code for a report (see example below) that basically queries up a database and displays the results in html. However, I need to display one of the fields as a hyperlink for a drill down.
The link would look like http://host.com/code/tier2.asp?value=x where x would be field4 in the code.

I am really struggling with this, under a deadline and any help would be appreciated.


Dim mySQL
Set ss = Server.CreateObject("ADODB.Recordset")
ss.ActiveConnection = conn
mySQL = "SELECT Field1, Field2, Field3, Field4 From TTable"

ss.Open mySQL

Dim i
Dim j
        %><TABLE BORDER="0"><TR><%
        For i = 0 To ss.Fields.Count - 1
            %><TD width ="22%"><B><%=ss.Fields(i).Name%></B></TD><%
        Next
        %></TR><TR></TR><TR></TR><%
        i = 1
        Do While Not ss.EOF
            %><TR<% if i mod 2="0" Then%>
             >
         <%Else%>
                >
         <%End if
            For j = 0 To ss.Fields.Count-1
                %><TD width ="22%"><%=ss.Fields(j).Value%></TD><%
            Next
            %></TR><%
            ss.MoveNext
            i=i+1
        Loop
ss.close
Set ss = Nothing
%>
</tr>
</TABLE>

  #2 (permalink)  
Old September 4th, 2006, 11:51 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This will write the correct value:

http://host.com/code/tier2.asp?value=<%=ss("field4")%>

"The one language all programmers understand is profanity."
  #3 (permalink)  
Old September 4th, 2006, 11:56 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess I was not clear. Sorry. I need the code to process the fields to make one of them a hyperlink without making other fields a hyperlink. Sorry for the confusion, but you response was appreciated.
  #4 (permalink)  
Old September 4th, 2006, 05:42 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You mean inside of a Crystal Drill Down report? Or are you just trying to display this as HTML on a web page?

"The one language all programmers understand is profanity."
  #5 (permalink)  
Old September 5th, 2006, 04:03 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HTML on a web page. However, I was able to modify some code posted here from Jonax (http://p2p.wrox.com/topic.asp?TOPIC_ID=4138) that does 95% of what I want. The only thing I need now is to figure out how to provide a delimited list of fields that I used in the select clause to not display in the HTML output, but still be available to use as part of the hyperlink.

Code:



<%
Dim ReportSDate
Dim ReportEDat
ReportSDate = Request.Form("StartDate")
ReportEDate = Request.Form("EndDate")
Session("ReportStartDate") = ReportSDate
Session("ReportEndDate") = ReportEDate
%>


<%
'Procedure to create a table
sub MakeTable(SourceIn, sLinkURL, iIdField, sLinkFields)
dim Field, objField, bLinkIt, t
dim aLinkFields
aLinkFields = split(lcase(sLinkFields),",")

Set oRSmtr = Server.CreateObject("ADODB.Recordset")
oRSmtr.ActiveConnection = conn
oRSmtr.Open SourceIn

response.write "<table border=0><tr>"
For Each Field in oRSmtr.Fields
    response.write "<th>" & Field.name & "</th>"
next
'response.end
Do while not oRSmtr.EOF
    response.write "<tr>"
    For each objField in oRSmtr.fields
        bLinkIt = FALSE
        for t = 0 to ubound(aLinkFields,1)
            if aLinkFields(t) = lcase(objField.name) then
                bLinkIt = TRUE
                exit for
            end if
        next

        if bLinkIt = TRUE then
            response.write "<td><a href='" & sLinkURL & oRSmtr.fields(iIdField) & "'>" & objField.value & "</a>&nbsp;</td>"
        else
            response.write "<td>" & objField.value & "&nbsp;</td>"
        end if
    Next
    oRSmtr.movenext
    response.write "</tr>"
loop
response.write "</table>"
oRSmtr.close
set oRSmtr=nothing
end sub
%> </p>
<%call MakeTable("SELECT field1, field2, field3, field4, field4 FROM table WHERE stuff", "./somepage.asp?ID=", 0, "field1")%>
</p>


Similar Threads
Thread Thread Starter Forum Replies Last Post
display field dcae103103 Beginning PHP 1 October 24th, 2007 04:30 PM
Using ID in hyperlink field pagey ASP.NET 2.0 Basics 4 October 7th, 2007 01:12 PM
Accessing text in a hyperlink field mvyjim ASP.NET 2.0 Professional 0 March 10th, 2007 05:22 PM
Using Hyperlink field in GridView asp_convert ASP.NET 2.0 Basics 2 February 7th, 2007 07:33 PM
Datagrid with Hyperlink display more fields in pg vnasibi ASP.NET 1.x and 2.0 Application Design 1 September 28th, 2004 03:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.