Your DateTime should be nullable for a start.

Then, when constructing your query, if your DateTime is null, you add
DBNull.Value to the query. Within your query just check if @MyDateVar IS
NULL and act accordingly.



On Thu, Feb 3, 2011 at 5:34 PM, Gourav <[email protected]> wrote:

> Hi All,
> I am creating a panel in which User hav to enter His Professional
> Working Experience
> There is Date of Joinning is Mandatory but date of Resignation is
> optional..So here i am facing problem to send NULL value in Database..
> In database my Datatype is DATETIME
> I already used many type but i didn't get solution.:
>
> i). DateTime dt = new DateTime();
>    dt = null;
> ii)  string stringTest = null;
>    DateTime dateTimeTest = null;
> iii) SqlDateTime sqldatenull ;
>     SqlDateTime sqldatenull ;
>     cmd.Parameters ["@Date"].Value =sqldatenull ;
> iv) System.DBNull.Value
> v)
> .
> .
> .
>
> No one is handle to this situation..SO pls tell me how to handle this
> problem.I'll wait for ur reply and Thanks in advanced for your
> fantabulous  answers...
>
>

Reply via email to