Wrox Programmer Forums
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 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
Old November 11th, 2008, 02:29 PM
Authorized User
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Making a link to documents in ADO/ASP

Hi Everyone,
     I am trying to make a field/Column in my database(Access) to display as links to documents in my ASP page. But here is the tricky part.

These links are links to different documents.

The names for these links are supplied by the user not in code but by typing it into a textbox and by typing the path to the document in another textbox regardless of the name of the document.

The user after providing this information will post it to the display form that shows the content of the database and should be able to view the name and click on the name to open a document of any sort.

This is ADO/ASP if you are wondering what i am using to script.

Finally, How can i do this?

All suggestions are welcome

Thank you in advance

Old November 11th, 2008, 04:41 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

First of all, do *NOT* fall into the trap of using the "hyperlink" data type in Access for the column. That data type is really only useful from within Access and is worthless when used from ADO/ASP. Instead, just use an ordinary text column (size no larger than 255).

Other than that, I'm not sure what you are asking. Assuming you have two fields in your DB, DocName and DocLink (my arbitrary names), you would just need to do
SQL = "SELECT DocLink, DocName FROM yourtable WHERE ..."
Set RS = yourAlreadyOpenConnection.Execute( SQL )
Do Until RS.EOF
    <A HREF="<%=RS("DocLink")%>"> <%=RS("DocName")%> </A>
Of course, whether the paths (DocPath) supplied by the users will work or not for *OTHER* users will depend entirely on the nature of the paths that the user types in.


EDIT NOTE: OOPS! I left the RS("...") off of the DocName originally! That's probably the source of all the confusion!
Old November 12th, 2008, 12:44 PM
Authorized User
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts

First, Thank you for your help

I tried what you showed me above and it sort of works. But below is what i did and I am not sure where i am going wrong

<TABLE BORDER=1 COLS=<% = oRs.Fields.Count %>>
    <%Dim oField
    For Each oField In oRs.Fields %>
      <TH> <% = oField.Name %></TH>
      <% Next %>

<%Do While Not oRs.EOF %>
   <%For Each oField In oRs.Fields%>
This is where you may need to look
       <A HREF= "<%= oRs.Fields("Link")%>">Click </A>
       <%If IsNull(oField) Then
           Response.Write "&nbsp;"
           Response.Write oField.Value
         End If

       <% Next
    <% Loop %>

 <A HREF= "<%= oRs.Fields("Link")%>">Click </A>

The output is i would say almost close to what i am trying to accomplish.

Let me define a few things for you:
 "Link" is the name of the Field/Column I am trying to turn into links such that when a user clicks on any text in this field it would open a document.

"Click" was just a test I put in there to see what would happen when i run my ASP page

The output is like this

In the field named "Link" there are text values there but now when i run my code "Click" appears beside this text values in this Field(Link)

"What i am trying to do is make those text values in the field (Link) become links to documents on my local drive."

 "Click" does not link to anything it just appears as a text with an underline.

The most tricky part is I dont want to supply the texts to this Field (link) in code i want to be able to suppy it in an HTML form and post it to my database as a link that opens up documents on my local or network drive.

Thank you very much for your help.

Any suggestions you have are welcomed.
Thank you.

Old November 12th, 2008, 01:57 PM
Authorized User
Join Date: Oct 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts

Thank you once again,
 Your code has worked it for me.
 All the names in that field/Column have been turned into links
Please ignore my last post.

Thank you so much

Similar Threads
Thread Thread Starter Forum Replies Last Post
Making a next and previous link using testing Aaron_j XSLT 0 July 28th, 2005 04:19 AM
how can i link to sql-server with ado.net[B)] zjxgjp ADO.NET 1 December 25th, 2004 09:50 AM
making a link bold knalle HTML Code Clinic 5 November 12th, 2004 11:46 AM
Making an email address link jks709 Classic ASP Databases 1 July 28th, 2004 01:14 PM
making a db field link on a page doranaz Classic ASP Databases 0 December 19th, 2003 01:13 PM

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