AJAX how to return Null values

When using responseXML to return values from an asp document it will not return a NULL value or a blank value from the database without holding up the responseXML. How can I properly handle Null values without having to have somthing in the database field.  Right now I must have a value in the database field or the AJAX script does not complete the script. So how can  XML / AJAX ignore  the Nulls.


function GetSystemEdit(SysID)
         xmlHttp = GetXmlHttpObject();
                       xmlHttp.onreadystatechange = ReturnGetSystem;
        xmlHttp.open('Get','EstimatesASP.asp?action=OpenSystem&SysID='+SysID, true);

function ReturnGetSystem()

 if (xmlHttp.readyState == 4)
            if (xmlHttp.status == 200)
                  var xmlDoc = xmlHttp.responseXML.documentElement;
                  var System = xmlDoc.getElementsByTagName('System')[0].childNodes[0].nodeValue;
                  var DateEntered = xmlDoc.getElementsByTagName('DateEntered')[0].childNodes[0].nodeValue;
                var EnteredBy = xmlDoc.getElementsByTagName('EnteredBy')[0].childNodes[0].nodeValue;
                  var Notes = xmlDoc.getElementsByTagName('Notes')[0].childNodes[0].nodeValue;
                  var RCSNotes = xmlDoc.getElementsByTagName('RCSNotes')[0].childNodes[0].nodeValue;
                  var TaxRate = xmlDoc.getElementsByTagName('TaxRate')[0].childNodes[0].nodeValue;
                  var MU = xmlDoc.getElementsByTagName('MU')[0].childNodes[0].nodeValue;
                  var SysID = xmlDoc.getElementsByTagName('SysID')[0].childNodes[0].nodeValue;

            alert('There was a problem with the request.');


Dim EstID
Dim System
Dim DateEntered
Dim EnteredBy
Dim TaxRate
Dim MU

SysID = CStr(Request.QueryString("SysID"))

XML = ""

      SQL = "SELECT * FROM Systems WHERE SystemID = "&SysID
      set rs=Server.CreateObject("ADODB.Recordset")
      rs.Open SQL, REDconnstring
      XML = XML + "<root>"      
      XML = XML + "<System>"&rs("System")&"</System>"
      XML = XML + "<DateEntered>"&rs("DateEntered")&"</DateEntered>"
      XML = XML + "<EnteredBy>"&rs("EnteredBy")&"</EnteredBy>"
      XML = XML + "<Notes>"&rs("Notes")&"</Notes>"
      XML = XML + "<RCSNotes>"&rs("RCSNotes")&"</RCSNotes>"
      'XML = XML + "<DateBid>"&rs("DateBid")&"</DateBid>"
      'XML = XML + "<DateWon>"&rs("DateWon")&"</DateWon>"
      XML = XML + "<TaxRate>"&rs("TaxRate")&"</TaxRate>"
      XML = XML + "<MU>"&rs("MU")&"</MU>"
      XML = XML + "<SysID>"&SysID&"</SysID>"
                     XML = XML + "</root>"

    set rs = nothing
      response.ContentType = "text/xml"

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

XML = XML + "<root>"      
      XML = XML + "<System>" & rs.Fields("System").value & "</System>"
      XML = XML + "<DateEntered>" & rs.Fields("DateEntered").value & "</DateEntered>"
      XML = XML + "<EnteredBy>" & rs.Fields("EnteredBy").value & "</EnteredBy>"
      XML = XML + "<Notes>" & rs.Fields("Notes").value & "</Notes>"
      XML = XML + "<RCSNotes>" & rs.Fields("RCSNotes").value & "</RCSNotes>"
      'XML = XML + "<DateBid>" & rs.Fields("DateBid").value & "</DateBid>"
      'XML = XML + "<DateWon>" & rs.Fields("DateWon").value & "</DateWon>"
      XML = XML + "<TaxRate>" & rs.Fields("TaxRate").value & "</TaxRate>"
      XML = XML + "<MU>" & rs.Fields("MU").value & "</MU>"
      XML = XML + "<SysID>" & SysID & "</SysID>"
                     XML = XML + "</root>"

Open in new window

waf771Author Commented:
Still does not work. If the Notes field, for example, is empty in the database then the AJAX comand will not complete and nothing loads on my page, however if I put something back in that field then everything loads fine. So somehow it does not like an empty database field.
try using this:
SQL = "SELECT System,DateEntered,EnteredBy,Nz(Notes,'') as theNotes ,RCSNotes,DateBid,DateWon,TaxRate,MU FROM Systems WHERE SystemID = " & SysID

and instead of:
XML = XML + "<Notes>" & rs.Fields("Notes").value & "</Notes>"
XML = XML + "<Notes>" & rs.Fields("theNotes").value & "</Notes>"
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

waf771Author Commented:
That comes up with "There was a problem with the request".  Can you Explain.......Nz(Notes,'') as theNotes .....to me?.
>>Can you Explain.......Nz(Notes,'') ...
Basically Nz acts as an If-Else.

Intead of
..., Nz(notes,'') as theNotes, ...

..., IIF(notes,notes,'') as theNotes, ...

If that still doesn't work try:
..., IIF(Not isNull(notes),notes,'') as theNotes, ...

waf771Author Commented:
mmmm..I still get "There was a problem with the request".  I traded out IIF for IF   and it still does not seem to work...  I also traded out ..., IIF(Not isNull(notes),notes,'') as theNotes, ...   For just 'Notes'  as well as changed ....rs.Fields("RCSNotes").value..... back to  ....rs.Fields("Notes").value.....and it works fine so long as there is no null,  so i know the rest of my syntax is good.  
waf771Author Commented:
By the way I am using SQL 2005, and not Acess. That may make a diffrence.
Nz is for access. Try:

SQL = "SELECT System,DateEntered,EnteredBy, COALESCE(Notes,'') as theNotes ,RCSNotes,DateBid,DateWon,TaxRate,MU FROM Systems WHERE SystemID = " & SysID

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
waf771Author Commented:
Thanks so much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.