How do I handle an empty set?

M

middletree

Using Classic ASP 3/VBScript

My query looks like:

strSQL = "SELECT Personal.FName, Personal.LName "

strSQL = strSQL & "FROM GroupInfo INNER JOIN "

strSQL = strSQL & "Personal ON GroupInfo.PersonalID = Personal.PersonalID "

strSQL = strSQL & "WHERE GroupID = "&strHHGroupID&" "




In a couple of rare cases, the result set will be empty. I am trying to
handle this before I start my next query, but when I try:

if Len(rsGroup("FName")) < 1 or IsNull(rsGroup("FName")) or
rsGroup("FName") = "0" then

It doesn't catch it, for some reason. What's the preferred way of doing
this? Should I use "If Rowcount < 1 then" ?
 
A

Anthony Jones

middletree said:
Using Classic ASP 3/VBScript

My query looks like:

strSQL = "SELECT Personal.FName, Personal.LName "

strSQL = strSQL & "FROM GroupInfo INNER JOIN "

strSQL = strSQL & "Personal ON GroupInfo.PersonalID = Personal.PersonalID
"

strSQL = strSQL & "WHERE GroupID = "&strHHGroupID&" "

Do web search on the term "SQL Injection Attack". Do not use concatenation
to include parameters into a query.
In a couple of rare cases, the result set will be empty. I am trying to
handle this before I start my next query, but when I try:

if Len(rsGroup("FName")) < 1 or IsNull(rsGroup("FName")) or
rsGroup("FName") = "0" then

It doesn't catch it, for some reason. What's the preferred way of doing
this? Should I use "If Rowcount < 1 then" ?

After you first aquire the recordset if its empty the EOF property will be
true.

If rsGroup.EOF Then
'Specail handling of empty set
Else
'Begin standard handling here
Do Until rsGroup.EOF
'per row output
Loop
'End standard handling here
End If
 

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,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top