Re: date as null

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Steve C. Orr [MVP, MCSD] (Steve_at_Orr.net)
Date: 01/12/05


Date: Wed, 12 Jan 2005 14:59:17 -0800

Date.MinValue = January 1, 0001.
This is why the stored procedure chokes on it.
You need to check for this special value and instead pass DBNull.Value to
the stored procedure.

-- 
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"JIM.H." <JIMH@discussions.microsoft.com> wrote in message 
news:95ECE058-7325-48AE-B072-F935F4F57DC4@microsoft.com...
>I did Date = Date.MinValue and Date has only time value liek 12:00:00 and
> when I try to call stored procedure it gives me out of range. Does
> Date.MinValue give a default date? If yes, what is it? I am using 1/1/1950 
> as
> default date.
>
>
> "Steve C. Orr [MVP, MCSD]" wrote:
>
>> The Date variable type cannot be null.  It must have a value.
>> Most people use Date.MinValue (or Date.MaxValue) to represent a null date 
>> in
>> their code.
>>
>> Example:
>> Dim MyDate as Date = Date.MinValue
>>
>> As for inserting it in the database, the other guys already specified 
>> that
>> DBNull.Value is what you'll want to use.
>>
>> -- 
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>>
>> "JIM.H." <JIMH@discussions.microsoft.com> wrote in message
>> news:ED62033C-3935-4DE0-A023-81AF0C37ED00@microsoft.com...
>> > Hello,
>> > I am calling a stored procedure to update my table.
>> > If one of the date on the screen left empty, I need to send date as 
>> > null.
>> > Since MyDate="" gives error in asp.net, how should I do this?
>> > Thanks,
>> > Jim.
>> >
>>
>>
>> 


Relevant Pages

  • Re: date as null
    ... If you need to pass it to a stored procedure, and you require a value, you ... If you allow nulls, just use DBNull.Value. ... >> Steve C. Orr, MCSD, MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Looping through a Datagrid
    ... Nicholas Paldino [.NET/C# MVP] ... What you can do is instead of attaching to the reader, ... >> to an OleDbCommand representing your stored procedure. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: DataReader with unknown number of columns
    ... - Sahil Malik [MVP] ... > I'm using a SqlDataReader to return results from a stored procedure where ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: delete a system sp
    ... > Vyas, MVP (SQL Server) ... >> how to rename or delete a stored procedure .. ...
    (microsoft.public.sqlserver.security)
  • Re: Not been able to get OUTPUT values from stored procedure in Query Analyser
    ... Vyas, MVP (SQL Server) ... declare @n1 varchar ... When I run the stored procedure from Query Analyser I do not value of output ...
    (microsoft.public.sqlserver.programming)