Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Closed Thread
 
LinkBack (2) Thread Tools
Old August 25th, 2004, 10:55 AM   2 links from elsewhere to this Post. Click to view. #1
Highly Reputable Member
 

Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 courtjester is on a distinguished road
Selecting database records using the QueryString

Ok, can anyone please explain this to me . Hey Smokie, I used the Exact title . thanks for your help guys.
courtjester is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 25th, 2004, 06:55 PM   #2
WebForumz Admin Badge
 

Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118 Webforumz Staff is on a distinguished road
sSQL = "SELECT whatever FROM wherever WHERE userid=" & request.querystring("id")

mypage.asp?id=5
Webforumz Staff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 26th, 2004, 04:07 AM   #3
Highly Reputable Member
 

Join Date: Jul 2003
Location: Ipswich, UK
Posts: 686
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Smokie will become famous soon enough
thats it Court Jester
Smokie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 26th, 2004, 08:56 AM   #4
Highly Reputable Member
 

Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 courtjester is on a distinguished road
ok, I see the code, but how do I get that to work for me? Where do I place that code? Does it go as a part of my link? Still confused.. thanks.
courtjester is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 26th, 2004, 09:09 AM   #5
Rob
Elite Veteran
SuperMember
 
Rob's Avatar
 

Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Rep Altering Power: 0 Rob is a jewel in the rough Rob is a jewel in the rough Rob is a jewel in the rough
Court Jester... you really have answered your own question here in your initial post.

You include the ID of the item you want from the database in your link (as a querystring)... eg:- mypage.asp?id=272

and then use the SQL select statement you posted to get at the element in the db who's id matches. you can pull whatever data you need to from the database (i know you know how to do that, so wont go into it) and display it.
__________________
Rob - Webforumz Founder
Web Designer Support Network || Personal Project: Sanctuary for Student Midwives
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 26th, 2004, 09:38 AM   #6
Highly Reputable Member
 

Join Date: Jul 2003
Location: Ipswich, UK
Posts: 686
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Smokie will become famous soon enough
for example:

Code:
Set objRS = objConn.Execute("SELECT [ID],[Title] FROM table")
If objRS.EOF Then
  Response.Write "no records"
Else
  Do While Not objRS.EOF
    Response.Write "<a href=details.asp?ID="&objRS("ID")&">"&objRS("Title")&"</a>
"
  objRS.MoveNext
  Loop
End If
objRS.Close
Set objRS = Nothing
The above will create something like this:

Code:
<a href=details.asp?ID=1>Mr Smith</a>

<a href=details.asp?ID=2>Mrs Jones</a>

<a href=details.asp?ID=3>Mr Small</a>

<a href=details.asp?ID=4>Mrs West</a>
Does that help?
Smokie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 26th, 2004, 11:35 AM   #7
Highly Reputable Member
 

Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 courtjester is on a distinguished road
COOL! Thanks Rob for taking the confusion away . Thanks Smokie, that's a big help as well, This totally rocks!
courtjester is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 26th, 2004, 11:39 PM   #8
Highly Reputable Member
 

Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 courtjester is on a distinguished road
hrmmm I tried the code you gave me smokie, and while I understand what it does and all.. the way you did it is a lot different then I normally do it. I am getting an error on line 16 which is this:
Code:
Set objRS = objConn.Execute("SELECT [ID],[PageName] FROM Page")
and here's the entire thing...
Code:
<% Set connectionToDatabase=Server.CreateObject("ADODB.Connection")
connectionToDatabase.ConnectionTimeout=60
connectionToDatabase.Open "DSN=Mydatabase"

dim objRS
dim objConn
objRS = recordSet
objConn = connectionToDatabase

Set objRS = objConn.Execute("SELECT [ID],[PageName] FROM Page")
If objRS.EOF Then
  Response.Write "no records"
Else
  Do While Not objRS.EOF
    Response.Write "<a href=details.asp?ID="&objRS("ID")&">"&objRS("PageName")&"</a>"
  objRS.MoveNext
  Loop
End If
objConn.Close
Set objConn = Nothing
%>
thanks for your help

ohhh and this is the error....
Microsoft VBScript runtime error '800a01a8'

Object required: 'Provider=MSDASQL.1;E'

/tests/querystrings.asp, line 16
courtjester is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 27th, 2004, 05:15 AM   #9
Highly Reputable Member
 

Join Date: Jul 2003
Location: Ipswich, UK
Posts: 686
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Smokie will become famous soon enough
try this:

Code:
<%
Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionTimeout=60
objConn.Open "DSN=Mydatabase"

Set objRS = objConn.Execute("SELECT [ID],[PageName] FROM Page")
If objRS.EOF Then
  Response.Write "no records"
Else
  Do While Not objRS.EOF
    Response.Write "<a href=details.asp?ID="&objRS("ID")&">"&objRS("PageName")&"&lt/a>"
  objRS.MoveNext
  Loop
End If
objConn.Close
Set objConn = Nothing
%>
Smokie is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 27th, 2004, 11:30 AM   #10
Highly Reputable Member
 

Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 courtjester is on a distinguished road
Thanks a ton Smokie. It works great! Thanks so much for your help!
courtjester is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Old August 27th, 2004, 03:52 PM   #11
Highly Reputable Member
 

Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 courtjester is on a distinguished road
Ohhh here is my first test at this :wink:.

www.haeglodesigns.com/tests/querystrings.asp
courtjester is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Bookmarks

Tags
selecting , database , records , using , querystring


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/classic-asp/573-selecting-database-records-using-the-querystring.htm
Posted By For Type Date
sql server 2005 error ( This thread Refback February 22nd, 2009 05:02 AM
microsoft vbscript error: object required: 'Provider=msdasql.1' - Zuula Search This thread Refback January 9th, 2009 06:35 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing wildcards in a querystring jayaime Classic ASP 0 October 11th, 2006 03:02 PM
var = Request.QueryString(item) - why doesn't this work?! Donny Bahama Classic ASP 7 June 17th, 2006 04:43 AM
Selecting Numbers WillisTi Flash and ActionScript 1 November 16th, 2005 12:56 PM
request.querystring breeze76 Classic ASP 5 October 16th, 2005 10:35 AM
PLEASE HELP - Passing Variables in Querystring just_the_basix Classic ASP 40 September 3rd, 2004 06:46 AM


Search Engine Optimization by vBSEO 3.2.0 RC8