Wrox Programmer Forums
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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
Old February 3rd, 2007, 07:24 PM
Authorized User
Join Date: Jan 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default if or switch

Hello everyone,
This is the situation

I have a form that requires a user to input information. From the input a table will open and display data.

Since there are a lot of different choices (90+) would it be better and faster to use a SWITCH() rather than multiple IF statements?

this is an example of the code:

' test for locality and set table name

If request.form("tableName") = "LA" then
tablename = "LA_Codes"
End IF
 IF request.form("tableName") = "0082001" then
tablename = "North_Dakota"

I want to learn to do things the right way.
Old February 3rd, 2007, 08:12 PM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Since this all revolves around one FORM variable why not place the table name in the value that gets passed from the "tablename" value?

So then all you would ahve to do is:

tableName = Request.Form("tableName") and eliminate the need for convoluted code.

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Old February 4th, 2007, 04:00 AM
Authorized User
Join Date: Jan 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts

Now why didn't I think of that... That is sooooooooooooooo much easier and makes a lot more sense...
I knew the IF's were not the right choice but I couldn't think what else to do.
Thanks gbianchi!!!!

Similar Threads
Thread Thread Starter Forum Replies Last Post
switch statement crmpicco Javascript How-To 3 March 9th, 2015 10:37 PM
Switch mamatharocks Biztalk 0 May 22nd, 2008 11:29 PM
switch statement seymour_glass C# 5 January 24th, 2007 12:08 AM
C# switch statement nalla General .NET 4 December 14th, 2005 05:31 AM
Switch rajuru Beginning PHP 2 February 9th, 2005 11:24 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.