Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - db help please
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

db help please

 Post Reply Post Reply Page  12>
Author
huwnet View Drop Down
Senior Member
Senior Member


Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
Post Options Post Options   Thanks (0) Thanks(0)   Quote huwnet Quote  Post ReplyReply Direct Link To This Post Topic: db help please
    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
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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")) & ""
Back to Top
huwnet View Drop Down
Senior Member
Senior Member


Joined: 30 May 2003
Location: England
Status: Offline
Points: 1375
Post Options Post Options   Thanks (0) Thanks(0)   Quote huwnet Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadDog Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 06 December 2004 at 2:24am
Really?  I didn't know that, even when only selecting from the one table?
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.