Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 June 12th, 2003, 09:58 AM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default display data on the Fly

I have this old book called ASP techniques for web masters.
It has a section called Dynamic Web Sites.
In that section it state that I can create a page on the fly from data in a DB. My DB is running and I can display info.
I would like to be able to click the name of a person and have a new page created based on the name I click on the fly without having to create a page for each person in my DB.
The only line I have is
'Response.Write("<td><a href=display.asp?" & oRS("BName").Value & " target=_blank>" & oRS("BName").Value & "</a></td>")
a href=display.asp? I was trying to download the code for this page that would show me how to pass the BName on to the display.asp page for it to creat the page base on the data for that BName.

Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
__________________
Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old June 12th, 2003, 11:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

The display ASP page would create a recordset using ADO and then display the results..

In the example you posted oRS is a recordset object that contains the results of the SELECT from the database. Then the line that you have pasted is used to display that result.

Does that help a little?

Hal Levy
Daddyshome, LLC
 
Old June 12th, 2003, 11:50 AM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First I display the list of People on a Page called list.asp using a normal select from line. The list.asp page loads basic info about a person and it works fine.
But
Once the list.asp page is loaded, I then wanted to click the name of the person and have a new page disply thier bio and more detailed info.

From the example I had seen in the book, I guessed that I could just pass the BName or ID data in that one record to pull info from that record to display an on the fly document. display.asp would just get the variable or whatever you call it from the list.asp page and display the info I choose to select.
I just can't figure out how to get the variable thing to pass on to the next page.
Is there an example of a List of Data that has a link that transfers to a second page to diplay furthur data?
The Book said I could download the code but the book is old.

Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old June 12th, 2003, 02:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Jeff,

That's exactly what you would do. You pass the primary key for that record (when they click on the link for the name) to the detail display page. Then on the detail page you again go to the database to read the details.

Who published the book?


Hal Levy
Daddyshome, LLC
 
Old June 12th, 2003, 02:43 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:
Who published the book?
Wrox Press Copyright 1998

I see the picture and a description of it working but it refers to a URL for the code and the URL is gone.

In stead of trying so hard I think I'll just use overlib to popup a small window with the details.

Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old June 12th, 2003, 09:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I may be comming in late here but the problem might be with your query string.

Code:
Response.Write("<td><a href=display.asp?" & oRS("BName").Value & " target=_blank>" & oRS("BName").Value & "</a></td>")
The querystring needs a name to identify each of the fields being passed theName=theValue

so the above code should read

Code:
Response.Write("<td><a href=display.asp?BName=" & oRS("BName").Value & " target=_blank>" & oRS("BName").Value & "</a></td>")
Note the 'BName=' after the display.asp?

Sorry if I'm off the mark!
 
Old June 16th, 2003, 03:26 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is so simple it is hard.

I wanted to create a string called strBName
to pass the BName from the first page.
I then wanted to create another page based on that string.

Page two would be like.
strSQL = "select Bio FROM Table1 where BName='" & strBName &"'"

I think thi is what I needed to do, Right?

I could also get the same effect with.
strSQL = "select * FROM Table1 where BName='" & strBName &"'"

My question was how do I word the first page to creat the string strBName when I am creating the page dynamically already. I assume I would define the string in the <a href somewhere
I just don't know how to define the string based on data being displayed from a recordset I had already created.


Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old June 18th, 2003, 10:48 AM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get how to pass one thing on to the next page.
The URL would look like this
display.asp?BID=2

Now BID is defined as 2
I wanted to select a field called BIO from a table
called BANDS where a field named ID is equal to the
the BID that is now 2.

The BID is defined in the URL of the first page and is passed to
the second page. I got that. How do I now take that value that is
passed and use it in the Select * form Bands where ID=BID

Jeff Henderson
President-Worship Loud
http://www.worshiploud.com
 
Old June 18th, 2003, 07:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The SELECT string would look like this:

Code:
strSQL = "select BIO from BANDS where ID = " & request("BID")
Assuming that the ID is a numeric field.
If you get that working you should also validate the value of BID to make sure strSQL is a valid SQL string.
If the field is blank or not a number the database will return an error.
The best way to do this is to put it into a variable then validate it.
Code:
dim BID
BID = request("BID")
if BID = "" then
'the field is blank do not do the database query and send a message to the user of the error
else 
if not isnumeric(BID) then
'the field is not a number do not do the SQL query and send a message to the user of the error
end if
else
'all is well use the string to do the query
strSQL = "select BIO from BANDS where ID = " & request("BID")
Conn.execute(strSQL)
end if
Conn is the database connection that would be set up for this page.
Do you have a Connection to your database set up as yet?
 
Old June 23rd, 2003, 01:37 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got it a few days ago,

The mistake I kept making was that I am on Brinkster and they are wierd with how things are displayed. This is how I got it to work.
 PAGE1
    Response.Write("<td><center><a href=display.asp?BID=" & oRS("ID").Value & " target=_blank><img src=info.gif alt=Profile></a></center></td>")

 PAGE2
Dim BID
sSQL = "SELECT Name, Info, Bio, URL FROM Table1 WHERE ID = " & BID


Thanks for the Input!


Jeff Henderson
President-Worship Loud
http://www.worshiploud.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display data in MSHFlexgrid Swati Chari VB How-To 3 July 22nd, 2008 10:15 AM
Display data within data range? ktsis ASP.NET 1.0 and 1.1 Basics 2 June 9th, 2006 03:06 PM
display data in the dropdown vivek_inos Access VBA 1 November 25th, 2005 07:02 PM
Display data in a subform marcin2k Access VBA 1 March 1st, 2005 04:37 PM
Display Data. mistry_bhavin ADO.NET 2 May 4th, 2004 09:22 AM





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