Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Not IsNull

Status
Not open for further replies.

IS300

MIS
Oct 29, 2003
121
CA
I currently have a web form where the user can enter a date in the format MM/DD/YYYY. This box is optional, so the user can leave it blank. I have a SQL Server 2000 database running in the back that would get this information. The data type for this SQL file is smalldatetime and it allows for null values.

If the user leaves that date field blank, I get an error, saying "type mismatch".

What I tried to do was an if statement that would only insert data into the database if the form was was not null. Otherwise it would do nothing. Here is the code:
Code:
IF NOT(IsNull(Request.Form("OrderedDate"))) Then
			rs("OrderedDate") = Request.Form("OrderedDate")
End If

Is that the correct way to do it? Or will SQL need me to insert a value anyways?

Thanks in advance
 
IF Request.Form("OrderedDate")<>"" Then
rs("OrderedDate") = Request.Form("OrderedDate")
End If

-DNG
 
also you can see if it is a valid date using isdate() function...google for it...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top