i've come across a real head-hurter. I'm looping through a recordset and
response.writin g it's rows out with no problem except 1 field. The field
type is varchar and contains words like meeting, holiday, etc.
Problem is, I'm trying to render a "n/a" when the field is null as in
LISTING 1 below. My code isn't catching the null values. How can I test for
null values? I could swear I've successfully used the Len() test like below
successfully on similiar null varchar fields, but perhaps not.
Any ideas?
LISTING 1:
If Len(objRS(7)) < 1 Then
xTeamName= "n/a" ' this is problem line
Else
xTeamName = objRS(7)
End If 6 5564
Why not do this in the query? You can use COALESCE(col, 'n/a') in SQL
Server, or NULLIF or IIF in Access.
Or, instead of the way you're doing it,
rs7 = trim(objRS(7))
if len(rs7) = 0 then rs7 = "n/a"
response.write rs7
I'm guessing there is a blank space, not a NULL value, and hence
len(objRS(7)) = 1, and falls into the else.
"scott" <sb*****@milesl umber.com> wrote in message
news:ek******** ******@TK2MSFTN GP14.phx.gbl... i've come across a real head-hurter. I'm looping through a recordset and response.writin g it's rows out with no problem except 1 field. The field type is varchar and contains words like meeting, holiday, etc.
Problem is, I'm trying to render a "n/a" when the field is null as in LISTING 1 below. My code isn't catching the null values. How can I test for null values? I could swear I've successfully used the Len() test like below successfully on similiar null varchar fields, but perhaps not.
Any ideas?
LISTING 1:
If Len(objRS(7)) < 1 Then xTeamName= "n/a" ' this is problem line Else xTeamName = objRS(7) End If
first, what is COALESCE?
I found the culprit, I inserted zeros for null values, staying up too late
again.
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartr eb.noraa> wrote in message
news:eb******** ******@TK2MSFTN GP10.phx.gbl... Why not do this in the query? You can use COALESCE(col, 'n/a') in SQL Server, or NULLIF or IIF in Access.
Or, instead of the way you're doing it,
rs7 = trim(objRS(7)) if len(rs7) = 0 then rs7 = "n/a" response.write rs7
I'm guessing there is a blank space, not a NULL value, and hence len(objRS(7)) = 1, and falls into the else.
"scott" <sb*****@milesl umber.com> wrote in message news:ek******** ******@TK2MSFTN GP14.phx.gbl... i've come across a real head-hurter. I'm looping through a recordset and response.writin g it's rows out with no problem except 1 field. The field type is varchar and contains words like meeting, holiday, etc.
Problem is, I'm trying to render a "n/a" when the field is null as in LISTING 1 below. My code isn't catching the null values. How can I test for null values? I could swear I've successfully used the Len() test like below successfully on similiar null varchar fields, but perhaps not.
Any ideas?
LISTING 1:
If Len(objRS(7)) < 1 Then xTeamName= "n/a" ' this is problem line Else xTeamName = objRS(7) End If
Do you have SQL Server installed? If so, look in BOL (Books Online).
Start--Run---%windir%\hh.exe "C:\Program Files\Microsoft SQL
Server\80\Tools \Books\SQL80.co l"
(Or whatever directory SQL Server is installed in) http://search.microsoft.com/search/r...px?qu=coalesce
Ray at home
"scott" <sb*****@milesl umber.com> wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl... first, what is COALESCE?
I found the culprit, I inserted zeros for null values, staying up too late again.
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartr eb.noraa> wrote in message news:eb******** ******@TK2MSFTN GP10.phx.gbl... Why not do this in the query? You can use COALESCE(col, 'n/a') in SQL Server, or NULLIF or IIF in Access.
Or, instead of the way you're doing it,
rs7 = trim(objRS(7)) if len(rs7) = 0 then rs7 = "n/a" response.write rs7
I'm guessing there is a blank space, not a NULL value, and hence len(objRS(7)) = 1, and falls into the else.
"scott" <sb*****@milesl umber.com> wrote in message news:ek******** ******@TK2MSFTN GP14.phx.gbl... i've come across a real head-hurter. I'm looping through a recordset and response.writin g it's rows out with no problem except 1 field. The field type is varchar and contains words like meeting, holiday, etc.
Problem is, I'm trying to render a "n/a" when the field is null as in LISTING 1 below. My code isn't catching the null values. How can I test for null values? I could swear I've successfully used the Len() test like below successfully on similiar null varchar fields, but perhaps not.
Any ideas?
LISTING 1:
If Len(objRS(7)) < 1 Then xTeamName= "n/a" ' this is problem line Else xTeamName = objRS(7) End If
> first, what is COALESCE?
It is a built-in SQL Server function that takes 2 or more parameters, and
returns the first non-NULL value.
Oh, well, in your case I think that might be something like:
If IsNull(objRS(7) ) Then
xTeamName= "n/a" ' this is problem line
Else
xTeamName = objRS(7)
End If
Jth wrote: *Hi.
Did you try with the IsNull function in ASP?
This code worked for me:
if (IsNull (PokerConn.fiel ds("StandBy")) ) then Response.Write( "n/a") else Response.Write( PokerConn.field s("StandBy")) *
--
Jth
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
Hi.
Did you try with the IsNull function in ASP?
This code worked for me:
if (IsNull (PokerConn.fiel ds("StandBy")) ) then Response.Write( "n/a")
else Response.Write( PokerConn.field s("StandBy"))
scott wrote: *i've come across a real head-hurter. I'm looping through a recordset and response.writin g it's rows out with no problem except 1 field. The field type is varchar and contains words like meeting, holiday, etc.
Problem is, I'm trying to render a "n/a" when the field is null as in LISTING 1 below. My code isn't catching the null values. How can I test for null values? I could swear I've successfully used the Len() test like below successfully on similiar null varchar fields, but perhaps not.
Any ideas?
LISTING 1:
If Len(objRS(7)) < 1 Then xTeamName= "n/a" ' this is problem line Else xTeamName = objRS(7) End If *
--
Jth
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Moluske |
last post by:
The web site was on another server i switch to a new one but this server hav
now PHP Safe Mode to ON so i get error when creating thumbnail. I cant put
PHP Safe mode to OFF. is ther any thing i can do so it will be able to
create the thumbnail again ?
site: www.jfl-media.com
Thanks
J-F
her is the script:
|
by: Juho Saarikko |
last post by:
I made a Python script which takes Usenet message bodies from a database,
decodes uuencoded contents and inserts them as Large Object into a
PostGreSQL database. However, it appears that the to last few bytes
of uudecoded data are always mangled. Take a look of this hexdump output:
Originals (decoded with Pan, each line is from a different file):
000c2c0 e1bf 00ff 2541 a9e4 a724 d9ff
0011a10 ff54 00d9
00093e0 fb4f a80d ffd9 c200 ffef...
|
by: Edd Dawson |
last post by:
Hi. I have a strange problem involving the passing of command line
arguments to a C program I'm writing. I tried posting this in
comp.programming yesterday but someone kindly suggested that I'd have
better luck here. So here goes!
My program ignores any command line arguments, or at least it's
supposed to. However, when I pass any command line arguments to the
program, the behaviour of one of the functions changes mysteriously. I
have...
|
by: Ram Laxman |
last post by:
Hi all,
I have written the following code:
/* strtok example */
#include <stdio.h>
#include <string.h>
static const char * const resultFileName = "param.txt";
|
by: Fernando Barsoba |
last post by:
Dear all,
I have been posting about a problem trying to encrypt certain data using
HMAC-SHA1 functions. I posted that my problem was solved, but
unfortunately, I was being overly optimistic. I am really desperate now,
because I havent' been able to locate the origin of the problem for a
couple of days now..
PROBLEM: the message digest obtained differs each time I execute the
code, but works perfectly when applying the "control", that...
| |
by: imrantbd |
last post by:
This is my first problem.Please help me.
I have the following code:
<head>
<script language="JavaScript">
function addSrcToDestList() {
destList1 = window.document.forms.destList;
srcList = window.document.forms.srcList;
|
by: imrantbd |
last post by:
I need array type name like "destList" must use for my destlist select box,not a single name.Or need a solution to capture multiple value of "destList" select box and send all selected value in php page.The multiple select value then insert in database added by comma.The following is my code:
Form Page:form.php
<head>
<script language="JavaScript">
function addSrcToDestList() {
destList1 = window.document.forms.destList;
srcList...
|
by: DJG79 |
last post by:
Hi all,
I am using an open source menu that i found and it works great, except
for one thing that when the web page is not scrolled to the very top
the drop down links will not stay visible. Has anyone else had this
sort of problem with javascript? and any ideas how to fix it would be
greatly appreciated..
I have included a copy of the code below, thanks.
/**
|
by: sravani1 |
last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map and after displayed it.plz tell that how to start the logic.
<?php
// Connect to database
$errmsg = "";if (! @mysql_connect("localhost","root","sreeni")) {
$errmsg = "Cannot connect to database";
}
@mysql_select_db("my_db1");...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |