Case ASP Question

D

Dthmtlgod

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
 
B

Bob Barrows [MVP]

Dthmtlgod said:
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
 
M

Mark Schupp

Sound like a job for "IF" instead of case.

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

Hal Rosser

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
 
D

dlbjr

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!
 
E

Evertjan.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,901
Members
47,439
Latest member
elif2sghost

Latest Threads

Top