[thelist] 1/1/1900 SQL Server/ASP Question

Scott Schrantz scotts at rci-nv.com
Wed Jan 16 14:15:19 CST 2002


> -----Original Message-----
> From: josh [mailto:evolt at efeingold.com]

> I am updating a database field via a web form.  When a date 
> is placed in the field the database updates correctly.  When
> the form is left blank, the database assumes the value 1/1/1900. 
> 
> Does anyone know what I have done wrong? 

You need to put some logic in your code to deal with someone leaving the
date blank.

<code snippet type="revised">

ID = request.form("id")

If request.form("the_date") = "" Then
	TheDate = Date()  'Or whatever default date you want
Else
	TheDate = request.form("the_date")
End If

rs.Open "UPDATE t_table SET t_cr_ccss_review_date = '" & 
TheDate & "' WHERE id=" & ID

</code snippet> 

It's always a good idea to dump form fields into variables first, so you can
clean them up and validate them before passing them on to your SQL
statements.




More information about the thelist mailing list