Results 1 to 8 of 8

Thread: [RESOLVED] 'System.DateTime' and 'System.DBNull'

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    16

    Resolved [RESOLVED] 'System.DateTime' and 'System.DBNull'

    Hello,

    I'm trying to send a Null value in a DateTime field while calling my stored procedure.

    If I use this first method (short with one line), i got the following error message:

    cmd.Parameters["@p_order_date"].Value = (this.OrderDate == DateTime.MaxValue) ? DBNull.Value : this.OrderDate;

    Error Message:
    Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DateTime' and 'System.DBNull'


    However, it works correctly if I use the 2nd method:

    if (this.OrderDate == DateTime.MaxValue)
    {
    cmd.Parameters["@p_order_date"].Value = DBNull.Value;
    }
    else
    {
    cmd.Parameters["@p_order_date"].Value = this.OrderDate;
    }


    Can you help me to fix the problem with the first method ?

    Thank you

    Paul
    Last edited by paulnamroud; Jan 20th, 2011 at 02:52 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width