Print Page | Close Window

How Can I Create A Permalink?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=27205
Printed Date: 28 March 2026 at 7:36am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How Can I Create A Permalink?
Posted By: kennywhite
Subject: How Can I Create A Permalink?
Date Posted: 02 April 2009 at 2:25pm
Hello.
 
I have a page where database entries are displayed. I would like to create a link so that I can click on each entry to diplay all of the data from the entry seperately.
 
Like the permalink that you can click on here:
http://googleblog.blogspot.com/" rel="nofollow - http://googleblog.blogspot.com/
 
Thanks!
 
 
 



Replies:
Posted By: kennywhite
Date Posted: 18 May 2009 at 3:58pm
I've looked a lot and I can't find anything on the net that can tell me how to do this.
 
It is a pretty common function, so I must be missing something.
 
Can anyone help me figure out how to do this or give me a good link for helpful reading?
 
Thanks!


Posted By: Scotty32
Date Posted: 18 May 2009 at 7:24pm
If you know ASP it is very simple.

you make your link point to say:

site.com/details.asp?id=1


1 should be replaced with the unique ID from the database, you then grab it in the page doing:

<%
intID = Request.QueryString("id")
%>


and grab the information from your database like so:

<%
   strSQL = "SELECT * FROM tblTable WHERE id = " & intID & ";"
%>


Obviously this will need expanding and customising to fit your specific needs.




-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: kennywhite
Date Posted: 18 May 2009 at 8:50pm

Thanks for the example, but forgive me for I am a noob.  I was hoping that I did this right, but apparently I did not.

Here is the page I made. It is details.asp
 
I have a list of assets on one page and then when I click on one it will take me to this page with ?id=X at the end.  X would be the ID of whichever entry I click on, of course.
 
The exapmles that you have given me are marked in red below.
 

 
< mailto:%@LANGUAGE=VBSCRIPT" rel="nofollow - %@LANGUAGE="VBSCRIPT " CODEPAGE="1252"%>
 
 
 
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow - http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml" rel="nofollow - http://www.w3.org/1999/xhtml ">

<html>
<head>
<title>Assets - Indianapolis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../reports/simpleBlog.css" rel="stylesheet" type="text/css" />
<link href="styles/drop_down.css" rel="stylesheet" type="text/css" />
<link href="styles/menu5.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="white" text="black">
 
<%
'Dimension variables
Dim adoCon         'Holds the Database Connection Object
Dim rsAsset    'Holds the recordset for the records in the database
Dim strSQL         'Holds the SQL query to query the database
 
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

 'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("assets.mdb")
 'Create an ADO recordset object
Set rsAsset = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database DESCending order
strSQL = "SELECT assets.DeviceType, assets.Make, assets.Model, assets.Serial, assets.Asset,
assets.Department, assets.SiteCode, assets.User, assets.Condition, assets.Notes, assets.ID_no
FROM assets WHERE id = " & intID & ";"
 
%>
<%intID = Request.QueryString("id")%>
 
<%  Response.Write (rsAsset("Make"))%>
<%  Response.Write (rsAsset("Model"))%>
<%  Response.Write (rsAsset("Serial"))%>
 
 
What have I done wrong?


Posted By: Scotty32
Date Posted: 18 May 2009 at 10:06pm
You have placed the request for the id AFTER you have tried to use it.

You need to move the Request.QueryString("id") to the top of the page (after the first line)

Also, you may need to change "id" in the SQL statement to "ID_no" if this is your ID field (autonumber).

Also, for added security to prevent SQL Injection hacking attempts you may wish to use the following instead:

<%
   intID = Request.QueryString("id")
   if isNumeric(intID) then intID = clng(intID) else intID = 0
%>



-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: kennywhite
Date Posted: 19 May 2009 at 3:16pm
I'm still not able to get this to work.
 
I changed the auto number field in the database to "ID" to make this a little easier.
 
Here is my code now.
 

 
< mailto:%@LANGUAGE=VBSCRIPT" rel="nofollow - %@LANGUAGE="VBSCRIPT " CODEPAGE="1252"%>
<%   intID = Request.QueryString("id")   if isNumeric(intID) then intID = clng(intID) else intID = 0%>
 
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" rel="nofollow - http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml" rel="nofollow - http://www.w3.org/1999/xhtml ">

<html>
<head>
<title>Assets</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../reports/simpleBlog.css" rel="stylesheet" type="text/css" />
<link href="styles/drop_down.css" rel="stylesheet" type="text/css" />
<link href="styles/menu5.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="white" text="black">
 
<%
'Dimension variables
Dim adoCon         'Holds the Database Connection Object
Dim rsAsset    'Holds the recordset for the records in the database
Dim strSQL         'Holds the SQL query to query the database
 
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

 'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("assets.mdb")
 'Create an ADO recordset object
Set rsAsset = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database DESCending order
strSQL = "SELECT assets.DeviceType, assets.Make, assets.Model, assets.Serial, assets.Asset,
assets.Department, assets.SiteCode, assets.User, assets.Condition, assets.Notes, assets.ID FROM assets WHERE id = " & intID & ";"

'Open the recordset with the SQL query
rsAsset.Open strSQL, adoCon
%>
 

<%  Response.Write (rsAsset("Make"))%>
<%  Response.Write (rsAsset("Model"))%>
<%  Response.Write (rsAsset("Serial"))%>
<%
rsAsset.Close
Set rsAsset = Nothing
Set adoCon = Nothing
%>
 
 
 


Posted By: Scotty32
Date Posted: 21 May 2009 at 6:07pm
The second line needs to be on different lines, just as I posted it.


Also, if you continue to get errors it would be easier if you posted the error you get.
If you are just getting a standard "Page cannot be displayed" error you may need to read about http://www.webwiz.net/kb/asp_knowledgebase/500_internal_server_error.asp" rel="nofollow - HTTP 500 - Internal server error and how to turn off friendly http errors, to get to the real error.

-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: kennywhite
Date Posted: 22 May 2009 at 2:39pm

Oops, I had originally put that into two lines, but I must hit the delete key by mistake or something...

Still doesn't work, though.
 
Here is the error message that I am getting. It seems to be a problem with my SQL statement.
 
Error Type:
Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
/assets/details.asp, line 39, column 91
strSQL = "SELECT assets.DeviceType, assets.Make, assets.Model, assets.Serial, assets.Asset,
 
Thanks for helping!


Posted By: kennywhite
Date Posted: 22 May 2009 at 2:46pm
Ahhh...
 
I'm just an uber noob... Soory.
 
I thought I'd tried just the "*" in the SQL statement at first before manually adding in each field. If I did something else must have been screwed up because it works now.
 
Thanks for your help and patience


Posted By: Scotty32
Date Posted: 22 May 2009 at 5:34pm
Similar to the last error, but this time the other way round.


Your SQL Statement must be all on one line, unless you seperate the String

eg:

strSQL = "SELECT * FROM table"
strSQL = strSQL & " WHERE field = " & strValue & ";"




You have to be vary careful about your lines, you cant separate certain things out, and you cant spring them out on multiple lines as it tends to break things.


-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net