Wednesday, March 21, 2012

Problems with null values

I'm reading data with ADO into a recordset. From the recordset, I create an XML string.

Unfortunately, when I go from rst to XML, any null values are chopped off and don't appear in the XML tree. This causes problems in further developments.

It would appear that the easiest way to fix the problem is to guarrantee that there are no nulls in the output data.

I've tried ' ' + tbl.column as NewCol but when tbl.column is null, the result is null also.

suggestions?

For the record, for some damn reason the FOR XML RAW command does not work on my SQL. Don't know why, but I'm trying to find a work around.select coalesce(tbl.column,'') as newcol

replaces null with zero-length string

use 0 for numeric fields, i guess

rudy|||u can check the null value while retreiving the value from a recordset to a variable by iif(isnull(rsAdo("column")),"",rsAdo("column"))|||A variation of r937's answer:

SELECT IsNull(Field, 0) AS Field1
or
SELECT IsNull(Field, 'unknown') AS Field1

No comments:

Post a Comment