Print Page | Close Window

db help please

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=12829
Printed Date: 30 March 2026 at 11:05pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: db help please
Posted By: huwnet
Subject: db help please
Date Posted: 04 December 2004 at 1:01pm
Some more coding help please. Embarrassed

I need an ASP script that will display a specific record.

e.g. connect to table: articles

row defined in path name: /name.asp?id=1



Replies:
Posted By: dj air
Date Posted: 04 December 2004 at 1:13pm
does this example help i think you just want to get the record thats ID value xx key part is the where

strSQL = "Select tablename.field, FROM tablename WHERE tablename.recordID = " &  CLng(request.querystring("id")) & ""


Posted By: huwnet
Date Posted: 05 December 2004 at 9:12am
thanks, got it working. You will be able to see it in action when my new site goes live.


Posted By: Gullanian
Date Posted: 05 December 2004 at 1:13pm
When only selecting from one table you don't need to write tablename. in the select part.  This makes reading the code easier.

It's probably also better to store the ID in a variable which you have prevalidated as a numeric to provide the user with an nicer looking error if a nonnumeric Id has been entered, and also so you don't need to execute the clng() function on the ID in the query everytime you want to use it to save on processing power and make the code more readable.


Posted By: dpyers
Date Posted: 05 December 2004 at 10:02pm
Originally posted by Gullanian Gullanian wrote:

...
It's probably also better to store the ID in a variable which you have prevalidated as a numeric to provide the user with an nicer looking error if a nonnumeric Id has been entered, and also so you don't need to execute the clng() function on the ID in the query everytime you want to use it to save on processing power and make the code more readable.
 
It takes more resources to reference an object - like the request object - than a string. So if you need to reference a query or form field more than once in any code pass, you're better off from a performance standpoint to assign it's value to a string first.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: MadDog
Date Posted: 06 December 2004 at 1:22am
Originally posted by Gullanian Gullanian wrote:

When only selecting from one table you don't need to write tablename. in the select part.  This makes reading the code easier.


Makes it easier yes, makes the server work harder, YES.


-------------
http://www.iportalx.net" rel="nofollow">


Posted By: Gullanian
Date Posted: 06 December 2004 at 2:24am
Really?  I didn't know that, even when only selecting from the one table?


Posted By: Mart
Date Posted: 06 December 2004 at 2:55am
Originally posted by MadDog MadDog wrote:

Originally posted by Gullanian Gullanian wrote:

When only selecting from one table you don't need to write tablename. in the select part.  This makes reading the code easier.


Makes it easier yes, makes the server work harder, YES.


Where did you get that info from? I don't think it would make the server work that much harder


Posted By: dpyers
Date Posted: 06 December 2004 at 9:26am
Originally posted by Mart Mart wrote:

Originally posted by MadDog MadDog wrote:

Originally posted by Gullanian Gullanian wrote:

When only selecting from one table you don't need to write tablename. in the select part.  This makes reading the code easier.


Makes it easier yes, makes the server work harder, YES.


Where did you get that info from? I don't think it would make the server work that much harder
 
My understanding is the same as maddogs, but I couldn't give a specific source other than that an explicit reference is usually faster than a generic one.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Gullanian
Date Posted: 06 December 2004 at 10:14am
I understand that explicitness is faster than generic, but is this the case when only 1 table is being referenced?


Posted By: Gullanian
Date Posted: 14 December 2004 at 11:38am
Anyone found out what happens yet?



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