Help with this IF, Else, Else If and End If problem? ASP/VB

Hoping someone can help me with this. I have three database
tables,
orderdetails, paidorders, ordercomplete and the following
recordset:
<%
Dim rsOrderSearch
Dim rsOrderSearch_cmd
Dim rsOrderSearch_numRows
Set rsOrderSearch_cmd = Server.CreateObject ("ADODB.Command")
rsOrderSearch_cmd.ActiveConnection = MM_connNAME_STRING
rsOrderSearch_cmd.CommandText = "SELECT orderID, (SELECT
COUNT(*) FROM
dbo.tblpaidorders WHERE dbo.qryorderdetails.orderID =
dbo.tblpaidorders.orderID) AS PAIDORDER, (SELECT COUNT(*)
FROM
dbo.tblordercomplete WHERE dbo.qryorderdetails.orderID =
dbo.tblordercomplete.orderID) AS COMPLETEORDER,
itemdescription FROM
dbo.qryorderdetails WHERE orderID = ? OR customerID = ? OR
itemdescription
LIKE ? ORDER BY orderdate DESC"
rsOrderSearch_cmd.Prepared = true
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param1", 5, 1, -1,
rsOrderSearch__MMColParam) ' adDouble
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param2", 5, 1, -1,
rsOrderSearch__MMColParam1) ' adDouble
rsOrderSearch_cmd.Parameters.Append
rsOrderSearch_cmd.CreateParameter("param3", 200, 1, 255, "%"
+
rsOrderSearch__MMColParam2 + "%") ' adVarChar
Set rsOrderSearch = rsOrderSearch_cmd.Execute
rsOrderSearch_numRows = 0
%>
If the orderID appears in the ordercomplete table (thus
COMPLETEORDER would
have a COUNT value of 1), I want to display "Completed".
If the orderID appears in the paidorders table (thus
PAIDORDER would have a
COUNT value of 1), I want to display "Awaiting
Pickup/Delivery".
For everything else, I want to display "Open Job".
For some reason, the following doesn't display the "Awaiting
Pickup/Delivery" option, but seems to be displaying
"Completed" correctly.
I've tried various combinations, but it looks correct to me!
Is it?:
<%IF (rsOrderSearch.Fields.Item("COMPLETEORDER").Value)
> 0 Then%>
<span class="greentext">Completed</span>
<%Else%>
<%IF (rsOrderSearch.Fields.Item("PAIDORDER").Value) > 0
Then%>
<span class="orangetext">Awaiting
Pickup/Delivery</span>
<%Else%>
<span class="redtext">Open Job</span>
<%End If%>
<%End If%>
Also, the above code is in a table cell within a repeat
region. If I move
this to a different table cell within the same repeat region,
it doesn't
display at all! This seems more like a bug to be honest, but
considering
the above code doesn't work, I'm wondering if that is the
reason?
If anyone can help, I'd really appreciate it. Thanks.
Regards
Nath.

Hi,
Relating this to my other more recent post about the crash
when udpating
site cache, do you think that this:
<%IF (rsOrderSearch.Fields.Item("COMPLETEORDER").Value)
> 0 Then%>
<span class="greentext">Completed</span>
<%Else%>
<%IF (rsOrderSearch.Fields.Item("PAIDORDER").Value) > 0
Then%>
<span class="orangetext">Awaiting
Pickup/Delivery</span>
<%Else%>
<span class="redtext">Open Job</span>
<%End If%>
<%End If%>
...would be sufficient to corrupt my site, or site cache (or
whatever it
is!)? I had suspected my own personalisation of DW's
MM_Username to
MM_Username1 was causing the problem but, having just spent
an hour editing
every file within the sub-directory that is causing the
problems, in Notepad
(because DW crashes when I open them), and renaming my
MM_Username1 back to
MM_Username, I notice that DW is still crashing. So I have
ruled out the
MM_Username because this had been working fine anyway, up to
yesterday.
So...the only other thing I've done on the site is to add
this:
<%IF (rsOrderSearch.Fields.Item("COMPLETEORDER").Value)
> 0 Then%>
<span class="greentext">Completed</span>
<%Else%>
<%IF (rsOrderSearch.Fields.Item("PAIDORDER").Value) > 0
Then%>
<span class="orangetext">Awaiting
Pickup/Delivery</span>
<%Else%>
<span class="redtext">Open Job</span>
<%End If%>
<%End If%>
Would this crash my site cache? I'm really at a loss as to
what has
happened.
Can you have two COUNT(*) .... AS suchandsuch in one SELECT
statement? I
wondered if that was maybe it.
Would appreciate your help because, as it stands, I can't
open this
sub-directory in DW.
Thanks
Nath.
"Lionstone" <[email protected]> wrote in
message
news:[email protected]...
> It's not DW - it's ADO. TEXT/NTEXT are handled one way,
and all other
> types are handled another. It has to do with when and
how the data is
> retrieved, and the details are headache-inducing.
>
>
> Using a client-side cursor would also work since the
data is all
> retrieved, not retrieved as needed.
> "tradmusic.com" <[email protected]> wrote
in message
> news:[email protected]...
>> Hi,
>>
>> I'm hoping there's nothing wrong with my logic, but
I think I've spotted
>> the problem!
>>
>> Within that recordset, there is a field called
"deliverdetails". This is
>> an ntext field in my database.
>> Because this doesn't appear as the last field in the
list of fields in
>> the statement it causes "weird" things to happen.
>> I removed the reference to this field, and it's all
working!
>>
>> Sometimes I really don't understand why it would
cause other fields to
>> fail, or not function properly, but ntext fields are
just not handled
>> very well by DW 8.0.2. Groan.
>>
>> Thanks anyway Pizza.
>> Nath.
>>
>> "PizzaGood" <[email protected]> wrote in
message
>> news:[email protected]...
>>>I think the problem has to do with your logic.
>>>
>>> Can you give us some examples of the values for
a record, specifically
>>> the values for
>>>
>>> - COMPLETEORDER
>>> - PAIDORDER
>>>
>>> Like:
>>>
>>> - a paid order looks like this:
>>> - a complete order looks like this:
>>>
>>>
>>>
>>>
>>> "tradmusic.com"
<[email protected]> wrote in message
>>> news:[email protected]...
>>>> Hoping someone can help me with this. I have
three database tables,
>>>> orderdetails, paidorders, ordercomplete and
the following recordset:
>>>>
>>>> <%
>>>> Dim rsOrderSearch
>>>> Dim rsOrderSearch_cmd
>>>> Dim rsOrderSearch_numRows
>>>>
>>>> Set rsOrderSearch_cmd = Server.CreateObject
("ADODB.Command")
>>>> rsOrderSearch_cmd.ActiveConnection =
MM_connNAME_STRING
>>>> rsOrderSearch_cmd.CommandText = "SELECT
orderID, (SELECT COUNT(*) FROM
>>>> dbo.tblpaidorders WHERE
dbo.qryorderdetails.orderID =
>>>> dbo.tblpaidorders.orderID) AS PAIDORDER,
(SELECT COUNT(*) FROM
>>>> dbo.tblordercomplete WHERE
dbo.qryorderdetails.orderID =
>>>> dbo.tblordercomplete.orderID) AS
COMPLETEORDER, itemdescription FROM
>>>> dbo.qryorderdetails WHERE orderID = ? OR
customerID = ? OR
>>>> itemdescription LIKE ? ORDER BY orderdate
DESC"
>>>> rsOrderSearch_cmd.Prepared = true
>>>> rsOrderSearch_cmd.Parameters.Append
>>>> rsOrderSearch_cmd.CreateParameter("param1",
5, 1, -1,
>>>> rsOrderSearch__MMColParam) ' adDouble
>>>> rsOrderSearch_cmd.Parameters.Append
>>>> rsOrderSearch_cmd.CreateParameter("param2",
5, 1, -1,
>>>> rsOrderSearch__MMColParam1) ' adDouble
>>>> rsOrderSearch_cmd.Parameters.Append
>>>> rsOrderSearch_cmd.CreateParameter("param3",
200, 1, 255, "%" +
>>>> rsOrderSearch__MMColParam2 + "%") '
adVarChar
>>>>
>>>> Set rsOrderSearch =
rsOrderSearch_cmd.Execute
>>>> rsOrderSearch_numRows = 0
>>>> %>
>>>>
>>>> If the orderID appears in the ordercomplete
table (thus COMPLETEORDER
>>>> would have a COUNT value of 1), I want to
display "Completed".
>>>> If the orderID appears in the paidorders
table (thus PAIDORDER would
>>>> have a COUNT value of 1), I want to display
"Awaiting Pickup/Delivery".
>>>> For everything else, I want to display "Open
Job".
>>>>
>>>> For some reason, the following doesn't
display the "Awaiting
>>>> Pickup/Delivery" option, but seems to be
displaying "Completed"
>>>> correctly.
>>>> I've tried various combinations, but it
looks correct to me! Is it?:
>>>>
>>>> <%IF
(rsOrderSearch.Fields.Item("COMPLETEORDER").Value) > 0 Then%>
>>>> <span
class="greentext">Completed</span>
>>>> <%Else%>
>>>> <%IF
(rsOrderSearch.Fields.Item("PAIDORDER").Value) > 0 Then%>
>>>> <span class="orangetext">Awaiting
Pickup/Delivery</span>
>>>> <%Else%>
>>>> <span class="redtext">Open
Job</span>
>>>> <%End If%>
>>>> <%End If%>
>>>>
>>>> Also, the above code is in a table cell
within a repeat region. If I
>>>> move this to a different table cell within
the same repeat region, it
>>>> doesn't display at all! This seems more like
a bug to be honest, but
>>>> considering the above code doesn't work, I'm
wondering if that is the
>>>> reason?
>>>>
>>>> If anyone can help, I'd really appreciate
it. Thanks.
>>>> Regards
>>>> Nath.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Similar Messages

Maybe you are looking for

  • Dark bands or 'spotlights' on bottom of Macbook (early 2009) screen?

    I have had my 13" Macbook since 2009. It's never given me an issue but yesterday I opened up my computer from sleep mode and there were dark bands across the bottom in between what looked like small spotlights beaming towards the top of the screen (t

  • 9 Beeps when starting up

    My Late 2008 MBP has a strange problem today: when pressing power button, it took a long time (about 5-8 seconds) to respond, and it beeps 9 times (3 short, 3 long , then 3 short) along with the white LED at the front of the machine blinks. After tha

  • Keyboard creating loud fan noise after coffee spill

    After a coffee spill my keyboard has been creating my fans to run very loudly.  The temp. is still pretty normal at 40C.  When I have the computer on and disconnect the keyboard, the fans return to normal.  I've tried cleaning everything inside and r

  • Any possible dual presentation screen solution (Impress!ve+Writer)?

    Hello. I've made a presentation in LaTeX-Beamer and want to use Impress!ve to project it to the projector or the Smart Board (some kind of projector) via an VGA cable, how can I have a dual screen so I can view some notes from OpenOffice Writer on my

  • Error in - PCR -G013 -

    Hi , I got an error in GB Payroll - Under 'Gross Payment [time management, function - PIT , PCR - G013 , /001 Valuation basis 1 I am getting an error , which says-  Division by Zero not performed - Do any one have any idea why the PCR is broken half