RE:

  • 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

  • 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

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply