Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2004, 02:23 PM
Authorized User
 
Join Date: Apr 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default if condition (simple but mind blowing)

Hi:
 i have database text field named "value1", and this field is empty.

 now i fetch it and store it in variable like:
value1 = objCat.Fields("value1")

 now i check the condition, if value1 is empty then show "empty message" other wise show "not empty message". Like:

if value1 = "" then
   response.write "empty"
 else
   response.write "not empty"
 end if


 Simple :) but result is that, it always shows "not empty". If i put some values in value1 in database, then be no effect. it is shown "not empty"

Then i change my code like this:
if value1 <> "" then
   response.write "not empty"
 else
   response.write "empty"
 end if


now it is working correctly :(

i did not understand what is the problem with first code.
Can any one see any problem?

Burhan



 
Old October 22nd, 2004, 07:35 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Burhan,

  Check the first code with isnull function.


if isnull(value1) then
   response.write "No value"
else
   response.write value1
end if



---------
Rajani

 
Old October 24th, 2004, 08:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

In addition to that you can also check that this way.
Code:
if len(trim(value1)) = 0 then
   response.write "empty"
 else
   response.write "Not empty"
 end if
 Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old November 23rd, 2004, 12:16 AM
Authorized User
 
Join Date: Oct 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kiwibey
Default

actually i also always facing this problem....
finally i know hot to solve it yet....
haha..
thank you all of you...

bey

 
Old June 10th, 2005, 05:35 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

is the db field set to be a number or text?







Similar Threads
Thread Thread Starter Forum Replies Last Post
Mind map with Ajax TIA555 Ajax 0 June 28th, 2008 01:45 PM
Axys blowing out my server tomasdlv Windows Server 0 September 28th, 2006 06:42 PM
where condition...? mnr555 Crystal Reports 0 June 18th, 2006 05:32 PM
Stored Procedure Blowing Up ritag SQL Server 2000 4 November 2nd, 2004 12:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.