Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JScript: Scripting.Dictonary: problems with the empty string

JScript: Scripting.Dictonary: problems with the empty string

Scheduled Pinned Locked Moved Web Development
sysadminhelpquestion
2 Posts 2 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Carl in t Veld
    wrote on last edited by
    #1

    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?

    U 1 Reply Last reply
    0
    • C Carl in t Veld

      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?

      U Offline
      U Offline
      Uwe Keim
      wrote on last edited by
      #2

      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).

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups