473,320 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

select case statement

229 100+
Hi I have this query.

Expand|Select|Wrap|Line Numbers
  1. lngCategoryID=CLng(Request("CategoryID"))
  2. If lngCategoryID <> "" And lngCategoryID <> 0 Then
  3.  
  4.     Set connPostCardSoft=Server.CreateObject("ADODB.Connection") 
  5.     connPostCardSoft.Open PostCardSoftConnectString
  6.     Set rsCard=Server.CreateObject("ADODB.Recordset")
  7.     rsCard.CursorLocation = 3
  8.     SQLQuery="Select postcardid,DefaultHeadline,CardDescription,gallery,DefaultMessage,extrathree,Author,Artist,tip,NewImageOne,"
  9.     SQLQuery= SQLQuery & "NewImageTwo,titleimagesix,largeimageseven,ThumbnailURL,"
  10.     SQLQuery= SQLQuery & "SUM(tblLinkTrackerLog.hit_count) AS totalhits  From tblGreetingPostCards  LEFT OUTER JOIN "
  11.     SQLQuery= SQLQuery & "tblLinkTrackerLog ON "
  12.     SQLQuery= SQLQuery & "tblGreetingPostCards.postcardid = tblLinkTrackerLog.link_id "
  13.     SQLQuery= SQLQuery & "Where CategoryID=" & Clng(lngCategoryID) & " "
  14.     SQLQuery= SQLQuery & "GROUP BY postcardid,DefaultHeadline,CardDescription,gallery,DefaultMessage,extrathree,Author,Artist,tip,NewImageOne,"
  15.     SQLQuery= SQLQuery & "NewImageTwo,titleimagesix,largeimageseven,ThumbnailURL "
  16.     SQLQuery= SQLQuery & "ORDER BY SUM(tblLinkTrackerLog.hit_count) "
  17.     rsCard.Open SQLQuery, connPostCardSoft
  18.        rsCard.PageSize = 100
  19.        intPageCount = rsCard.PageCount
  20.  
  21.        If rsCard.EOF=True Then
  22.         response.redirect "./"
  23.        Response.End
  24.     End If
  25. End If

It works fine. Trouble is I want for search engine optimisation it not to throw up an error on the page when the page is visited without the query in the address, for example
www.mysite.com/directory.asp
www.mysite.com/directory.asp?categoryid=55
at the moment i get this error

Expand|Select|Wrap|Line Numbers
  1. icrosoft VBScript runtime error '800a01a8' 
  2. Object required: '' 
  3.  
  4. /directorycontentalt.asp, line 156
when the page is served just www.mysite.com/directory.asp


It has been suggested to me that I should write something along these lines.
select case categoryID
case 1 : showthem page1
case 2 : showthem page2
case 3 : showthem page3
case 4 : showthem page4
case else : showthem page0
end select

but I dont know how or where to write it. Any pointers would be great.
Thanks
Richard
Sep 16 '08 #1
3 2469
Krandor
50
When lngCategoryID does not have a value, you should just have some generic html page with your keywords so the search bots will be happy.

If you are getting an error message, it means that your filtering:
Expand|Select|Wrap|Line Numbers
  1. If lngCategoryID <> "" And lngCategoryID <> 0 Then
  2.  
is not working. Theoretically, it should just ignore your whole If statement and do nothing.

Personally, I use If Len(lngCategoryID)> 0 to test for empty variables. This works on both numerics and strings.

Try that and see if it works for you.
Sep 16 '08 #2
fran7
229 100+
Thanks Krandor,
That worked great
Richard
Sep 16 '08 #3
jhardman
3,406 Expert 2GB
Personally, I use If Len(lngCategoryID)> 0 to test for empty variables. This works on both numerics and strings.
Thanks for your suggestion. I tend to use
Expand|Select|Wrap|Line Numbers
  1. <> ""
but I haven't been fully satisfied with it, yours looks like a better idea.

Jared
Sep 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
15
by: grunar | last post by:
After some thought on what I need in a Python ORM (multiple primary keys, complex joins, case statements etc.), and after having built these libraries for other un-named languages, I decided to...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
4
by: deko | last post by:
When I loop through this function, it works fine until it hits End Function - then it jumps to End Select. Very strange... This behavior occurs when Case = 255. Any ideas why this is happening? ...
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
by: mark.irwin | last post by:
Hello all, Have an issue where a redirect pushes data to a page with a select case which then redirects to another page. Problem is the redirect isnt working in 1 case. Code below: strURL =...
8
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
2
by: scole954387 | last post by:
Hi, I have a problem. I have written a SQL statement that has a nested select case statement on the 'where' clause to condition the results. ...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
21
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.