| Author |
Topic Search Topic Options
|
huwnet
Senior Member
Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
|
Post Options
Thanks(0)
Quote Reply
Topic: db help please Posted: 04 December 2004 at 1:01pm |
Some more coding help please.
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
|
 |
dj air
Senior Member
Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
|
Post Options
Thanks(0)
Quote Reply
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")) & ""
|
 |
huwnet
Senior Member
Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 05 December 2004 at 10:02pm |
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.
|
 |
MadDog
Mod Builder Group
Joined: 01 January 2002
Status: Offline
Points: 3008
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 December 2004 at 1:22am |
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.
|
|
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 December 2004 at 2:24am |
|
Really? I didn't know that, even when only selecting from the one table?
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 December 2004 at 2:55am |
MadDog wrote:
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
|
 |