|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, July 14, 2010 12:32 AM
Points: 127,
Visits: 49
|
|
Hi, recently I needed to pass some null value as parameteres to a DateTime field, I was using SQL Server 2k and C# VS 2003. I tried using DBNull and others values but none fo them worked for me. What I did at the end was to set a default value of null in the database field, and didn't pass the parameter when I didn't have it, of course it added a little bit of logic when building the query. Is there anyway to pass null value in the param???
Kindest Regards,
@puy Inc
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, September 21, 2011 8:43 AM
Points: 115,
Visits: 315
|
|
To pass in a null to some stored procs (with older Vb6/ADO code) you can do this:
1) The VB code puts 1/1/1900 in the date and the proc converts it to null.
2) the proc code is shown below. ... set @NullDate = convert(smalldatetime, '1/1/1900')
if @aTestTime =@NullDate set @aTestTime = null ... Then your insert/update statement in the proc uses @aTestTime normally and this will put a null in the date field.
For our other code that generates insert and update statements just use null as you would in query analyzer.
Good luck
Doug
|
|
|
|