March 8th, 2012, 01:12 PM
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.
Now, when I run this exact same query directly using SQL Server Manager, it works just fine and inserts a NULL value.
dbCon.Execute("UPDATE Orders SET CompletedDate = Null WHERE ID="&Request.QueryString("id"))
March 8th, 2012, 08:49 PM
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.
Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.