If array is empty or null response.write "...." Help please
am 01.08.2005 18:52:26 von iam247
Hi
Firstly thanks to the number of people who have helped me with this
project over the past week.
Apologies in advance if I use ht eincorrect terms.
I have an array named rsGoupsP which is populated by a SQL statement -
it works fine and is later used to populate a drop down list in a form.
In some cases the result of the query will be empty or null (not sure
which is the correct term).
In these circumstances I want to stop the remainder of the script and
write a message to the screen eg "you are not a group leader".
The relevant sql and a pseudo attempt at what I have tried is below.
What do I need for the "If then loop", and can I do without an else?
Note I have 3 alternative "if then's" - all give an error message if
sql returns null / empty.
Thanks ColinK
'Create an ADO recordset object
Set rsGroupP = Server.CreateObject("ADODB.Recordset")
strSQL2 = "SELECT qryGroupPermission.* FROM qryGroupPermission WHERE
ContactID = " & (contactID("ContactID"))
'Open the recordset with the SQL query
rsGroupP.Open strSQL2, adoCon
'If this member is not a leader of any groups print the following
message
'If IsNull(rsGroupP("GroupID")) Then
'If IsEmpty(rsGroupP) Then
'If (rsGroupP) = "" Then
Response.write " You are not a group leader"
End If
...... rest of script
Re: If array is empty or null response.write "...." Help please
am 01.08.2005 19:04:01 von Steven Burn
'// On one line
'// If no records returned, write an error
If rsGroupP.EOF Then Response.Write "You are not a group leader":
Response.End
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
wrote in message
news:1122915145.976190.193030@o13g2000cwo.googlegroups.com.. .
> Hi
>
> Firstly thanks to the number of people who have helped me with this
> project over the past week.
>
> Apologies in advance if I use ht eincorrect terms.
>
> I have an array named rsGoupsP which is populated by a SQL statement -
> it works fine and is later used to populate a drop down list in a form.
>
> In some cases the result of the query will be empty or null (not sure
> which is the correct term).
>
> In these circumstances I want to stop the remainder of the script and
> write a message to the screen eg "you are not a group leader".
>
> The relevant sql and a pseudo attempt at what I have tried is below.
>
> What do I need for the "If then loop", and can I do without an else?
> Note I have 3 alternative "if then's" - all give an error message if
> sql returns null / empty.
>
> Thanks ColinK
>
> 'Create an ADO recordset object
> Set rsGroupP = Server.CreateObject("ADODB.Recordset")
>
> strSQL2 = "SELECT qryGroupPermission.* FROM qryGroupPermission WHERE
> ContactID = " & (contactID("ContactID"))
>
> 'Open the recordset with the SQL query
> rsGroupP.Open strSQL2, adoCon
>
> 'If this member is not a leader of any groups print the following
> message
>
> 'If IsNull(rsGroupP("GroupID")) Then
> 'If IsEmpty(rsGroupP) Then
> 'If (rsGroupP) = "" Then
>
> Response.write " You are not a group leader"
>
> End If
>
> ..... rest of script
>