You are here: Re: Seeking correct syntax to pass a NULL value for a datetime field from an asp page to SQL « MsSQL Server « IT news, forums, messages
Re: Seeking correct syntax to pass a NULL value for a datetime field from an asp page to SQL

Posted by Erland Sommarskog on 10/01/61 11:38

bjose21 (robert.jose@accenture.com) writes:
> Thanks for your responses. I was able to get around this within the asp
> code by basically stating..if there is a date in the field then write
> to SQL. However if there is no date then do not write anything to SQL
> for that particular field. Seems to be working great. Below is a sample
> of the asp code
>
>
> If IsDate(cDateClosed) Then
> sql = sql & ", dateClosed='"& cDateClosed & "'"
> End If

How do you format the date? If you format it as YYYYMMDD, this will
work. If you format it according to regional settings, it could fail,
or even worse result in an incorrect update like Jan 3rd being stored
as March 1st.

If you use parameterised statements, this can not occur.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация