#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    58
    Rep Power
    11

    Sending NULL Date Value


    This task is using classic ASP and MS SQL database. There is a "CompletedDate" field, which is a "Date" datatype that does allow Null values. The default value is Null for new entries.

    On this "update details" form, the user may or may not enter a date. However, I can't seem to pass a NULL value into the field if the user leave the date blank.

    Can somebody tell me where I am going wrong? Here is the insert code. I've stripped everything out except just the date insert. Upon execution, it inserts "1900/01/01" into the CompletedDate field.

    Code:
    dbCon.Execute("UPDATE Orders SET CompletedDate = Null WHERE ID="&Request.QueryString("id"))
    Now, when I run this exact same query directly using SQL Server Manager, it works just fine and inserts a NULL value.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,444
    Rep Power
    4539
    Just as a wild guess, I seem to recall there is a named ado variable something like adNull. But I've used similar code to set date columns to null with success.

    As an unrelated comment it's risky to pass unfiltered user input (request.querystring) directly to the database.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo