Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - if statement problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

if statement problem

 Post Reply Post Reply Page  12>
Author
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Topic: if statement problem
    Posted: 31 July 2003 at 8:37am

This should be really easy but ... it isn't working.

status on my db (sql server) has of 0 or 1.

0 for false and 1 for true.

So I am saying if that if the value is 0 then print "Open"

if not, print "Complete"

The value that is being printed is always "Open"

I tried this first:

Dim strStart,strFinal
If strStart = 0 then
  strFinal = " <font color=""#FF0000"">Open</font>"
else
  strFinal = " <font color=""#009900"">Complete</font>"
end if
Response.Write "<font color=""#000000"">" & strFinal& "</font>"

it didn't work.

Then I tried this below:

Dim strStart,strFinal
Do While Not rst.EOF
if strStart = 0 then
  strFinal = " <font color=""#FF0000"">Open</font>"
else
  strFinal = " <font color=""#009900"">Complete</font>"
end if
Response.Write "<font color=""#000000"">" & strFinal& "</font>"
rst.MoveNext

but still getting "Open" as value.

Please tell me what I am doing wrong.

 

 

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 9:20am
Where are you getting the value out of the database? Should it not be something like strStart = rst("Status") to set the value first??
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 9:45am

I do have that assignment in my code - strStart = rst("status").

I just missed, for some reason, including that line in my post to this forum.

So yes, that value was already assigned in my code.

Back to Top
Flamewave View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 June 2002
Location: United States
Status: Offline
Points: 376
Post Options Post Options   Thanks (0) Thanks(0)   Quote Flamewave Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 10:03am
Try casting the value to an integer: strStart = Int(rst("status"))
- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 10:20am

I actually did that; it didn't make any difference in result.

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 4:37pm
Try

If not Cbool(rst("status")) then
strFinal = " <font color=""#FF0000"">Open</font>"
else
strFinal = " <font color=""#009900"">Complete</font>"
end if
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 9:49pm

Nope, that didn't work!

What is so freaking annoying about this is that if I just leave it as rst("status"), it displays the result correctly; that is it displays either True or False but to make the result more meaningful to the user by using that simple if statement has been a nightmare.

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 01 August 2003 at 5:47pm

oh, i think sql server has problems with using 1 and 0 the way your using them. Try using 'y' and 'n' and see what happens...

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.