Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 9th, 2004, 08:06 AM
Authorized User
Join Date: Nov 2004
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to don baroo Send a message via Yahoo to don baroo
Default Making Retrieved Data Links


I have been able to retrieve data form my database but I want the data to appear as links when they are retrieved onto the form.

Any help will be appreciated.

Thank you.


Here is part of the code.

    Item Name: <INPUT TYPE="text" NAME="Keyword" VALUE=""> <INPUT TYPE="submit" VALUE=" Search ">
    <INPUT TYPE="hidden" NAME="Mode" VALUE="<%=MODE_RESULTS%>">
End Function

' This function will display the results of the search
Private Function ShowResults()
    Dim strConn ' Database connection string
    Dim SQL ' String that will have our SQL statments
    Dim RS ' Recordset object
    Dim Keyword ' Keyword for search
    Dim nRecCount ' Number of records found
    Dim nPageCount ' Number of pages of records we have
    Dim nPage ' Current page number

    ' Let's see what page are we looking at right now
    nPage = CLng(Request.QueryString("Page"))

    ' Let's see what user wants to search for today :)
    Keyword = Trim(Request.QueryString("Keyword"))

    ' define our SQL statment
    ' we will be looking for all the records in tblItem table
    ' where ItemName contains our Keyword
    ' do not forget to fix tick marks (single quotes) in our Keyword
    SQL = "SELECT * FROM asset WHERE asset_number LIKE '%" & Replace(Keyword, "'", "''") & "%'"

    ' Create our connection string
    strConn = GetConnectionString()

    ' Time to create and open recordset
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.CursorLocation = 3 ' adUseClient
    RS.Open SQL, strConn ' adOpenKeyset CursorType

    ' Start outputing HTML

    ' Did we find anything?
    If Not RS.Eof Then
        ' Let's deal with our findings

        ' Get records count
        nRecCount = RS.RecordCount

        ' Tell recordset to split records in the pages of our size
        RS.PageSize = RECORDS_PER_PAGE

        ' How many pages we've got
        nPageCount = RS.PageCount

        ' Make sure that the Page parameter passed to us is within the range
        If nPage < 1 Or nPage > nPageCount Then
            ' Ops - bad page number
            ' let's fix it
            nPage = 1
        End If

        ' Time to tell user what we've got so far
        Response.Write nRecCount & " record(s) found matching """ & Keyword & """.<br>"
        Response.Write nPageCount & " page(s) of results.<br>"
        Response.Write "Current page is " & nPage & ".<p>"

        ' Give user some navigation

        ' first page
        ' we link to this page with Page parameter = 1
        Response.Write "<A HREF=""" & SCRIPT_NAME & _
                "?Keyword=" & Keyword & _
                "&Mode=" & MODE_RESULTS & _
                "&Page=" & 1 & _
                """>First Page</A>"
        Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

        ' Previous Page
        ' we link to this page with Page parameter = Current Page - 1
        Response.Write "<A HREF=""" & SCRIPT_NAME & _
                "?Keyword=" & Keyword & _
                "&Mode=" & MODE_RESULTS & _
                "&Page=" & nPage - 1 & _
                """>Prev. Page</A>"
        Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

        ' Next Page
        ' we link to this page with Page parameter Current Page + 1
        Response.Write "<A HREF=""" & SCRIPT_NAME & _
                "?Keyword=" & Keyword & _
                "&Mode=" & MODE_RESULTS & _
                "&Page=" & nPage + 1 & _
                """>Next Page</A>"
        Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;"

        ' Last Page
        ' we link to this page with Page parameter = nPageCount
        Response.Write "<A HREF=""" & SCRIPT_NAME & _
                "?Keyword=" & Keyword & _
                "&Mode=" & MODE_RESULTS & _
                "&Page=" & nPageCount & _
                """>Last Page</A>"

        ' Start Results
        Response.Write "<p><b>Results:</b><br>" & String(20,"-")

        ' Position recordset to the page we want to see
        RS.AbsolutePage = nPage

        ' Let's output our records
        ' Loop through records until it's a next page or End of Records
        Do While Not (RS.Eof OR RS.AbsolutePage <> nPage)

            ' All we do here is just show the records
            Response.Write "<br>" & RS("asset_number")

            ' Move on to the next record
        ' We did not find anything
        Response.Write "Nothing found. Try again.<p><A HREF=""" & SCRIPT_NAME & """>Back</A>"
    End If

    ' Be nice - close the recordset

    ' Finish this page
End Function
'************************************************* ***********************************
'* End of Functions section
'************************************************* ***********************************


Reply With Quote
  #2 (permalink)  
Old December 9th, 2004, 11:23 AM
Friend of Wrox
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts

Response.Write "<br><a href='<%= rs("link_field")%>'>" & RS("asset_number") & "</a>"

Reply With Quote
  #3 (permalink)  
Old December 12th, 2004, 11:40 PM
Authorized User
Join Date: Dec 2004
Location: Palestine, Texas, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts

this is how i do it

<td width="80" nowrap>&nbsp<a href='link1.asp?teste=<%=strText%>'onclick="javasc ript:window.open" target="_blank"><%=objRs("text").Value%></td>

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate textbox with data retrieved from database hoailing22 ASP.NET 1.0 and 1.1 Basics 5 November 30th, 2006 12:13 AM
Compare retrieved records life_s Ng General .NET 2 April 11th, 2005 08:32 PM
retrieved data report problem rahmanbd Beginning VB 6 0 March 18th, 2005 08:52 AM
sorting retrieved data don baroo Classic ASP Basics 2 November 23rd, 2004 08:31 AM
have to hyperlink the data retrieved ractim ADO.NET 21 August 27th, 2004 09:34 AM

All times are GMT -4. The time now is 07:55 PM.

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