 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 25th, 2005, 12:53 PM
|
|
Registered User
|
|
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Newbie Needing Help
Hello,
I am still getting my feet wet with ASP and I have two questions I'm hoping someone can answer.
1. Can someone clarify when I should Dim? I understand using it to store variables while executing a script but I don't know if I need to use it to store values I'm pulling from a database and using/displaying. My main focus right now is database connectivity and adding, updating, deleting, sorting records. If anyone can recommend some good examples or a good reference book I would appreciate it.
2. Can someone explain the relationship between .Closed and = Nothing? When should I use a combination of the two versus only = Nothing? Should I use it for everything I've dim'ed? Here are the two examples I've seen thus far:
Example.Close
Set Example = Nothing
Set OtherExample = Nothing
Any feedback would be greatly appreciated.
Thanks,
Randall
|
|

February 25th, 2005, 01:38 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
.close oposite to .open
but With nothing you clear all settings to the object
Ahmed Ali
Software Developer
|
|

February 26th, 2005, 09:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;Can someone clarify when I should Dim?
Anytime you want to declaire a variable name you should Dim it. To ensure you do this evertime put:
<%= OPTION EXPLICIT %>
at the top of all your asp pages (prompts you to declaire any variables that you havnt)
;;;I don't know if I need to use it to store values I'm pulling from a database
Yes you do - EG:
[the following assumes you have created and opened a connection called conn]
Dim rs
sql = "Select ....."
set rs = conn.execuet(sql)
[the variable rs now holds your record set - when you have finished with your record set dont forget to set it to nothing EG set rs = nothing]
;;;Can someone explain the relationship between .Closed and = Nothing?
I am not sure about .Closed
In the example above you would use conn.close (our open DB connection) then set conn = nothing
Also above our record set named rs would be set to nothing after you have finished with it, as illustrated above.
Wind is your friend
Matt
|
|

March 4th, 2005, 06:11 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Think of a case where Example is a grocery store
When it is Nothing, it has some ability to pertain to a grocery store, but it does not curently pertain to any particular store.
If you asign it to the SafeWay at 6th & Main, it has some very specific properties:
The location
The color
The number of employees
etc.
That store can be .Open, in which case it is populated with employees, the lights are on, and so on.
The stroe is able to handle someone coming there to shop.
It can be .Closed, in which case it is not currently useful, though it has explicit properties that pertain to a real place.
If you arive with money, time to shop, and a shopping list you still cannot get any supplies; the store is .Closed.
The analogy doesn't fit in every respect, but it should help you to conceptualize the distinction.
|
|

May 19th, 2005, 12:20 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
".close" means that the providerstring/connectionstring in use with the obj. (when querrying a db) is no longer valid. Is ".close" only to use with a db?
".nothing" means setting the obj. value to nothing! Like canceling the value of a variable.
|
|

May 19th, 2005, 06:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
FYI
;;;".nothing" means setting the obj. value to nothing! Like canceling the value of a variable.
I am not sure what .nothing does, I have never used it - it should be:
set varName = nothing
;;;It can be .Closed, in which case..
I believe it should be .close not .closed
Wind is your friend
Matt
|
|
 |