I am getting wierd behaviour with IsNull in ASP. I am
passing a string (which may be null) to a function. When
the string is null, IsNull seems to return false the
first time it is called, then True the second time. The
code follows, am I doing something wrong, or is this a
bug?
Bob
function unquote(st) 'make database string suitable for
output
'############## ###
Dim test, test2
test = IsNull(st)
test2 = IsNull(st)
if test then
unquote=st
exit function
end if
response.write( "In unquote st = " & st & "; isNull(st)
=" & IsNull(st) & "; " & test & "; " & test2 & "<br>")
'if st is null, test is false, but test2 is true
st = replace(st, "&", "&")
st = replace(st, "'", "'")
st = replace(st, """, chr(34))
st = replace(st, "<br>", chr(13) & chr(10))
unquote = st
end function 2 14282
Bob Cottis wrote on 15 okt 2003 in
microsoft.publi c.inetserver.as p.general: I am passing a string (which may be null)
There is no such thing as a "null string" in vbs.
st = null is not a atring, so you cannot do replaces on it.
st = "" is an empty string, not a null, so:
isnull("") gives true
Perhaps you could, dependng on your application,
change the null variable to an empty string:
if isnull(st) then st = ""
?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
A much safer method than relying on null values (which can cause havoc with
outputing a recordset, for instance):
If Len(Trim(MyPoss iblyNullValue & " ")) = 0
'--- stuff here
End If
- Wm
--
William Morris
Product Development, Seritas LLC
"Bob Cottis" <an*******@disc ussions.microso ft.com> wrote in message
news:2b******** *************** ******@phx.gbl. .. I am getting wierd behaviour with IsNull in ASP. I am passing a string (which may be null) to a function. When the string is null, IsNull seems to return false the first time it is called, then True the second time. The code follows, am I doing something wrong, or is this a bug?
Bob
function unquote(st) 'make database string suitable for output '############## ### Dim test, test2 test = IsNull(st) test2 = IsNull(st) if test then unquote=st exit function end if response.write( "In unquote st = " & st & "; isNull(st) =" & IsNull(st) & "; " & test & "; " & test2 & "<br>") 'if st is null, test is false, but test2 is true st = replace(st, "&", "&") st = replace(st, "'", "'") st = replace(st, """, chr(34)) st = replace(st, "<br>", chr(13) & chr(10)) unquote = st end function This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Trev |
last post by:
I have two tables, tblMTO and tblIMPORT_MTO. If I import an entire MTO
into the import table I want to create a delta from it (i.e. leave only
the changed items). I have a view (simplified)
SELECT dbo.tblIMPORT_MTO.ImportID, dbo.tblIMPORT_MTO.MTONo,
dbo.tblIMPORT_MTO.Rev AS New_Rev, dbo.tblMTO.Rev AS Old_Rev
FROM dbo.tblIMPORT_MTO LEFT OUTER JOIN
dbo.tblMTO ON dbo.tblIMPORT_MTO.MTONo = dbo.tblMTO.MTONo
Now to get all rows...
|
by: Martin |
last post by:
Dear Group
Just wondered how I can avoid the CHAR(32) to be inserted if @String1 is NULL?
SET @String3 = ISNULL(@String1,'') + CHAR(32) + ISNULL(@String2,'')
Thanks very much for your expertise and efforts!
Best Regards,
|
by: Eric J Owens |
last post by:
TIA!
I recently moved some forms from an a2k mdb file to an a2k adp. There is
now an error when opening one of the forms 'the isnull function requires 2
arguments', but I only find references to IsNull() having 1 argument. Here
is an example of the offending code:
-----------------------------
Private Sub AEnd_DblClick(Cancel As Integer)
|
by: Paul Spratley |
last post by:
Hi all
Firstly this my first time posting to technical groups - so any
mistakes I apologise for in advance.
I am trying to count records in several secondary tables for the same
run in a primary table. However, there might be no records in these
secondary tables for the specific run. Hence the sql below returns
nulls.
|
by: Raoul Watson |
last post by:
I have used isNull statement for as long as I have used VB..
Recently I am devugging a program and it is very clear that the "IsNull"
function sometimes would return a true even when the value is not Null. Any
wild shot or theory as to why this is happening is appreciated. Also, any
other alternative is appreciated since I am stuck and cannot proceed without
fixing this issue (tried = Null and that doesn't work either).
Basically, I...
| |
by: madeleine |
last post by:
Please can someone help me, I think I may go mad with this one:
Do While Not IsNull(CDate(FormatDateTime(rst!F1.Value, vbShortDate)))
If IsNull(CDate(FormatDateTime(rst!F1.Value, vbShortDate)))
Then
MsgBox "this is not actually possible"
End If
-
|
by: Hexman |
last post by:
Hello All,
In SS EE I have nulls in a column. I want to select and eventually change to a zero (its a smallint column). I've tried selecting 'null', 'dbnull',
etc. Then I read about the ISNULL function. From the example I got, I received the "...requires 2 arguments...." error. Read up on it but it
doesn't click with me.
Could someone explain the error? And secondly, how to select null fields?
Thanks,
|
by: jimm.sander |
last post by:
Hello,
Problem: Im using isnull() in vbscript to determine if a field returned
from a ado object call is in fact null. The problem is when I use
isnull in anything other than a response.write() I get the following
error:
Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the
requested name or ordinal.
|
by: kcdoell |
last post by:
Hello:
When I write new record I have the following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!RowIsActive = False
'When a user is creating a new record the following code inserts the MonthID, YearID and
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |