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

    Join Date
    Apr 2004
    Rep Power

    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.

    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
    Rep Power
    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
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton

IMN logo majestic logo threadwatch logo seochat tools logo