JScript: Scripting.Dictonary: problems with the empty string
-
I don't understand how in ASP empty strings are handled. I check if if a field in a resultset has indeed a value. If not, I'll add "" to the dictionary. Afterwards, I want to use the items in the dictonary but there's not "" in some fields, but the Object-type null! So I have to test on it and set the string to "" myself :( // oRs is a ADODB.ResultSet // d is a Scripting.Dictionary
e = new Enumerator(oRs.Fields); for (;!e.atEnd();e.moveNext()) {
i= e.item(); if (typeof(i.value) != "unknown")
d.add(i.name, i.value);
else d.add(i.name, "");
} arr = (new VBArray(d.Keys())).toArray for (i in arr) {
q1= d(arr[i]); if (q1 == null) q1= ""; q= Server.HTMLEncode(q1);
}
Can anyone help me?
-
I don't understand how in ASP empty strings are handled. I check if if a field in a resultset has indeed a value. If not, I'll add "" to the dictionary. Afterwards, I want to use the items in the dictonary but there's not "" in some fields, but the Object-type null! So I have to test on it and set the string to "" myself :( // oRs is a ADODB.ResultSet // d is a Scripting.Dictionary
e = new Enumerator(oRs.Fields); for (;!e.atEnd();e.moveNext()) {
i= e.item(); if (typeof(i.value) != "unknown")
d.add(i.name, i.value);
else d.add(i.name, "");
} arr = (new VBArray(d.Keys())).toArray for (i in arr) {
q1= d(arr[i]); if (q1 == null) q1= ""; q= Server.HTMLEncode(q1);
}
Can anyone help me?
This is a database-issue, not an ASP-one. NULL-values in a database (even in text-fields) are not the same as empty strings! In MS Access, I think there is an option of allowing a text-field to contain empty values (e.g. ""). But its always a good idea to check for NULL. In VBScript: if IsNull(q1) then, in JScript as you did, I think (never used JScript in ASP myself).