Wrox Programmer Forums
|
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
 
Old August 4th, 2004, 06:07 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pulling data from an Access DB onto an ASP page

So I have one page that lists approx. 50 member organization links
on my company website. When one of these links is clicked on, you are directed to an ASP page that lists that specific company's description and includes a link to the company's website.
However, some companies have yet to develop websites. For those companies, I'm trying to have text appear that states "No page available" with no link below it. The info populating the organization description page comes from an Access DB - the field being "Website" (the "Web" part of the code below is included because the field on the form where this information is entered by data entry employees is set to kick in the "http://" part of the URL when someone begins typing in that form field)

So, in plainer English, I want the code to look in the "Website" field for each company, and if there is a website entered, to publish a link to the page on my description page. If there is no website entered, I simply want the "No page available" text to appear - without a link.

The code below functions in that it posts the text above but still includes a link to about:blank.

<%If rs("Website") <> "" Then
Web="http://"
Web=Web&rs("Website")
End If
%>
<%
If IsNull (rs("Website")) Then
response.write "<br>No page available"
End If
%>
' This part sets up the hyperlink to the company's page'
<br><a href="<%= Web %>" target="newUW"><%Response.write rs("Company_Name")%></a></p>

Thanks for any help that can be offered. Any fresh perspective would be appreciated.
 
Old August 4th, 2004, 07:33 PM
Authorized User
 
Join Date: Jun 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could try this:
<%If rs("Website") <> "" Then
    Web="http://"
    Web=Web&rs("Website")
    Response.Write (the code for your hyperlink)
Else
    response.write "<br>No page available"
End If
%>
 Without seeing all of the relevant code it is hard to be more helpful, but basically you can set up a variable containing EITHER the HTML for the hyperlink or the NO Page Available text, then Response.Write the variable.

HTH
Pat

-------------------
System 3 2000 Limited
www.system3-2000.co.uk
 
Old August 5th, 2004, 08:20 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the help.
The aspect of the syntax I'm actually struggling with is around that first response.write. I'm not actually hardcoding in hyperlinks (hyperlinks are pulled from an Access Database from a field called "Website" and then combined with the "Web" element in my code to generate the link for each individual member organization).
Therefore, when I attempt to follow your advise, I create this nonfunctional code:
<%If rs("Website") <> "" Then
Web="http://"
Web=Web&rs("Website")

Response.Write <a href="<%= Web %>" target="newUW"><%Response.write rs("Company_Name")%></a></p>
'above is where I try to create the hyperlink - which is the "Company_Name" field listed in the DB'

Else
response.write "<br>No page available"
End If
%>

The syntax is obviously incorrect but it seems to me that
<% Web %> needs to be included somehow in that response.write in order to call the websites listed within the database.

Thanks again for any assistance.
Melissa


 
Old August 5th, 2004, 08:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

It is always better to check for length of that database value. Else you will have to check for both Zero Length String and Databse NULL value. If you check of either of that, you would always miss the other and end up in error.
Code:
If len(rs("Website")) > 0 then
Should help.

Also change that response.write as this.
Code:
Response.Write "<a href='<%=Web%>' target='newUW'>" & rs("Company_Name") & "</a></p>"
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old August 5th, 2004, 09:49 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the input.
I added your code and get this error:
Microsoft VBScript compilation error '800a0409'

Unterminated string constant

/fbc/aboutus/inmembers2.asp, line 133

Response.Write "<a href='<%=Web
--------------------------------ˆ




 
Old August 5th, 2004, 11:49 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please modify it as:

Response.Write "<a href='" & Web & "' target='newUW'>" & rs("Company_Name") & "</a></p>"


Om Prakash
 
Old August 6th, 2004, 08:57 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Om!
The website works great now.

Melissa

 
Old August 6th, 2004, 09:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Melissa,

That was my bad. Didn't have thought that I was using code render tag there within response.write, sorry about that.

<%=Web%>

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
SSIS Not pulling data correctly chevy SQL Server 2005 0 February 26th, 2008 04:12 PM
Pulling Looped XML Data Into ASP.NET Page kwilliams ASP.NET 2.0 Professional 2 January 22nd, 2008 11:34 AM
pulling data from webpage zeeonline XSLT 3 July 27th, 2006 03:04 PM
Secure MSAccess db ASP Data Page Integration Will Woodward Classic ASP Databases 1 October 26th, 2005 08:32 AM
retrieving images from Access DB into asp page programmer_scs Classic ASP Databases 1 November 30th, 2004 10:19 AM





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