|
|
 |
August 25th, 2004, 10:55 AM
|
#1
|
|
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
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.
|
|
|
August 25th, 2004, 06:55 PM
|
#2
|
Join Date: Jul 2003
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 118
|
sSQL = "SELECT whatever FROM wherever WHERE userid=" & request.querystring("id")
mypage. asp?id=5
|
|
|
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
|
thats it Court Jester
|
|
|
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
|
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.
|
|
|
August 26th, 2004, 09:09 AM
|
#5
|
|
Elite Veteran
SuperMember
Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Thanks: 28
Thanked 22 Times in 19 Posts
|
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.
|
|
|
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
|
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?
|
|
|
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
|
COOL! Thanks Rob for taking the confusion away  . Thanks Smokie, that's a big help as well, This totally rocks!
|
|
|
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
|
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
|
|
|
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
|
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")&"</a>"
objRS.MoveNext
Loop
End If
objConn.Close
Set objConn = Nothing
%>
|
|
|
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
|
Thanks a ton Smokie. It works great! Thanks so much for your help!
|
|
|
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
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|