Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: General / Current Version (Old)
 asp coding: select case
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

RDoGG2k1
Starting Member

6 Posts

Posted - 08 July 2001 :  22:30:28  Show Profile
hey. i have a question for asp gurus:

i am planning to have sidebar tables at my site for "statistics, recently seen, latest classified ads, etc." and figured it would be easier to change the style if it would be contained in one subroutine.

therefore, i created this sub:


<%
sub ShowContent(type)

select case type

case stats
title = "Statistics"
text = "Please welcome our newest member:"
text = text & "blah, blah, blah"

case recentlyseen
title = "Members seen within 24 Hours"
text = "blah, blah, blah"

....................


case else
title = "Other Content"
text = "Unsupported content. Please contact the [url=admin@mysite.com]administrator[/url].

end select

response.write "<table><tr><td>" & title & "</td></tr>" & VBCRLF
response.write text & VBCRLF
response.write "</td></tr></table>" & VBCRLF

end sub
%>



now, in each of the cases, a database query will probably be used. what i want to know is if they will be called each time I call this script.

i.e.:

i plan on calling this script in inc_top:


<table><tr><td width="175">
<% ShowContent(stats) %>
<% ShowContent(recentlyseen) %>
.................
</td>
<td width="100%">


and in inc_footer:


</td></tr></table>


===================
RDoGG2k1.
===================

RDoGG™
Junior Member

USA
329 Posts

Posted - 08 July 2001 :  22:51:49  Show Profile  Visit RDoGG™'s Homepage  Send RDoGG™ an AOL message  Send RDoGG™ a Yahoo! Message
two 's

would this work?

and

would the sub connect to the database for each case everytime the subroutine is called?

RDoGG™
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 09 July 2001 :  02:16:49  Show Profile
If I understand what you're asking, I believe the answers are 'yes' and 'yes'


======
Doug G
======
Go to Top of Page

RDoGG™
Junior Member

USA
329 Posts

Posted - 09 July 2001 :  07:23:54  Show Profile  Visit RDoGG™'s Homepage  Send RDoGG™ an AOL message  Send RDoGG™ a Yahoo! Message
quote:

If I understand what you're asking, I believe the answers are 'yes' and 'yes'


======
Doug G
======



so the database would be called about 5 times each time the subroutine is called?

RDoGG™
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 09 July 2001 :  13:22:45  Show Profile
I don't know about 5 times. If you put database code in your function, it will execute whenever you call your function and won't execute if you don't call the function.

If your db code is in the case code, then only the case that is true will execute db code.


======
Doug G
======
Go to Top of Page

RDoGG™
Junior Member

USA
329 Posts

Posted - 09 July 2001 :  17:38:24  Show Profile  Visit RDoGG™'s Homepage  Send RDoGG™ an AOL message  Send RDoGG™ a Yahoo! Message
quote:

I don't know about 5 times. If you put database code in your function, it will execute whenever you call your function and won't execute if you don't call the function.

If your db code is in the case code, then only the case that is true will execute db code.


======
Doug G
======



ok. thanks. i understand. about the 5 times, i meant that if i had 5 cases that each called the db and one case else, that each time the subroutine is called, the DB would be queryed for each of the cases.

but, thanks to you, this is not true, which is good!



RDoGG™
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07