473,326 Members | 2,813 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,326 software developers and data experts.

Case ASP Question

I have this below. If there are 0 records, I want to do nothing, which it
does. I need to perform a task if there is more than one. Case > 1 doesn't
work. The most records I would have are 5.

mycount=rs.recordcount

Select Case mycount

Case 0

Response.write ("No Records")

Case 1

Do Something


Jul 22 '05 #1
6 1279
Dthmtlgod wrote:
I have this below. If there are 0 records, I want to do nothing,
which it does. I need to perform a task if there is more than one.
Case > 1 doesn't work. The most records I would have are 5.

mycount=rs.recordcount

Select Case mycount

Case 0

Response.write ("No Records")

Case 1

Do Something


Basic debugging:
response.write mycount

If mycount does not contain the correct count of records (which it will not
with the default cursortype), then your case statement cannot work:

See here for better ways (GetRows) to count records:
http://www.aspfaq.com/show.asp?id=2193
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
Sound like a job for "IF" instead of case.

If mycount=0 then
...
else
...
end if

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Dthmtlgod" <do************@netzero.net> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
I have this below. If there are 0 records, I want to do nothing, which it
does. I need to perform a task if there is more than one. Case > 1 doesn't work. The most records I would have are 5.

mycount=rs.recordcount

Select Case mycount

Case 0

Response.write ("No Records")

Case 1

Do Something

Jul 22 '05 #3
Yes, b/c depending on the cursor you're using, recordcount might actually
be -1. That property isn't always populated.

You should instead do

if rs.eof then
' no data
else
'it has data
end if

--
Ben Strackany
www.developmentnow.com

<a href="http://www.developmentnow.com">dn</a>
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Dthmtlgod wrote:
I have this below. If there are 0 records, I want to do nothing,
which it does. I need to perform a task if there is more than one.
Case > 1 doesn't work. The most records I would have are 5.

mycount=rs.recordcount

Select Case mycount

Case 0

Response.write ("No Records")

Case 1

Do Something
Basic debugging:
response.write mycount

If mycount does not contain the correct count of records (which it will

not with the default cursortype), then your case statement cannot work:

See here for better ways (GetRows) to count records:
http://www.aspfaq.com/show.asp?id=2193
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 22 '05 #4
If the rs.EOF and rs.BOF are both true you "have no records"
it the safest way to test I've come across
... and I think its "Case is > 1" .... not that it will work here anyway

"Dthmtlgod" <do************@netzero.net> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
I have this below. If there are 0 records, I want to do nothing, which it
does. I need to perform a task if there is more than one. Case > 1 doesn't work. The most records I would have are 5.

mycount=rs.recordcount

Select Case mycount

Case 0

Response.write ("No Records")

Case 1

Do Something

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
Jul 22 '05 #5
rs.Open
If Not rs.EOF Then
Do While Not rs.EOF
'Do Something
rs.MoveNext
Loop
End If
rs.Close

'dlbjr
'Pleading sagacious indoctrination!
Jul 22 '05 #6
dlbjr wrote on 17 nov 2004 in microsoft.public.inetserver.asp.general:
rs.Open
If Not rs.EOF Then
Do While Not rs.EOF
'Do Something
rs.MoveNext
Loop
End If
rs.Close


This works just the same:

rs.Open
Do While Not rs.EOF
'Do Something
rs.MoveNext
Loop
rs.Close

And this works just the same:

rs.Open
Do Until rs.EOF
'Do Something
rs.MoveNext
Loop
rs.Close

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
7
by: John | last post by:
Why does the System.IO.FileSystemEventArgs (in FileSystemWatcher object) return lower case for the file? i.e. e.FullName will return "c:\testingfilename.xml" instead of the origiiinal...
10
by: Lakshmi Narayanan.R | last post by:
Hi Experts, Using keyword "To" in select case giving error.The following code is got from www.microsrosoft.com itself. What is the wrong with this?. <% Dim Number1 Number1 = 7 ' Initialize...
11
by: Martin | last post by:
In Plauger's THE STANDARD C LIBRARY (1992) there is the source code for fabs.c (p140). /* fabs function */ #include "xmath.h" double (fabs)(double x) { switch (_Dtest(&x)) { /* test for...
16
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
1
by: jl2886 | last post by:
First question: I have an assigned ID that is based on the month and year and then the numbered case. For example, If a new policy came in in March of 07 and he was the 67th person who was entered...
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),...
55
by: aarklon | last post by:
Hi, why general integer expressions are not allowed in case labels in switch statements..????
6
by: Derik | last post by:
Okay, I THINK this is a PHP question... I've been mucking with PHP for awhile now, but just recently I've been poking at some ajax stuff, and I ran into something confusing; my Queries were...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.