Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

If isempty - inserting &nbsp into a database

Posted on 2004-10-16
5
Medium Priority
?
390 Views
Last Modified: 2013-11-13
You would this this would be a no-brainer, but I'm having difficulty...

If the user leaves a field blank, I want to insert "&nbsp" into the database. No big deal. Problem is, I must have it scripted incorrectly because what I have returns absolutely nothing.

Take a look:

if NOT isempty (Request.Form("BusName")) then
x = Replace(Request.Form("BusName"),"'","''")
else
x = "Hello"
end if

response.write x

When Request.Form("BusName") is empty, while there's no error on the page, "x" doesn't register at all. I get a blank page as opposed to "Hello".

What am I missing?
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:david_barker
ID: 12330290
Try this :
if Request.Form("BusName")="" then
0
 
LVL 6

Expert Comment

by:david_barker
ID: 12330292
Sorry, I meant :
if Request.Form("BusName")<>"" then
0
 
LVL 1

Expert Comment

by:scanadmin
ID: 12333159
david_barker is correcet, however, i would use
If Len(Trim(Request.Form("BusName"))) > 0 Then....

incase users insert spaces into 'blank' fields e.t.c
0
 

Author Comment

by:brucegust
ID: 12338338
scanadmin...

You've got my vote, friend. Thank you both for taking the time to help me out. David, your suggestion worked, but scanadmin is anticipating some user error and I'm thinking that's wise.

scanadmin, could you please explain to me "Len". I've never seen that before and I would be interested in knowing what it's doing from a code perspective.

Thanks!
0
 
LVL 1

Accepted Solution

by:
scanadmin earned 80 total points
ID: 12340748
Len is a predefined function in VB asn VBScript.

It takes one string argument and returns a number telling you how long it is.

e.g Len("hello") would return 5 as would s = "hello", len(s)

In the ASP Example above, we use Trim() to get rid of whitespace then len to see if there are more than 0 characters.

Hope this helps
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Six Sigma Control Plans

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question