Date time datatype problem in c#.net in windows application.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • seemabhagat
    New Member
    • Apr 2010
    • 3

    Date time datatype problem in c#.net in windows application.

    hi,


    I am using sqlserver for db in c#net windows application.
    I have taken field invoicedate its datatype is datetime field.
    when i am insertime datetime picker selected value it gives error

    (The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
    The statement has been terminated.)

    but this error is given only for today date.not for another selected date.

    my code is

    (Insert into Demo_Test(Cust_ Name,Entry_Date )values('" + txtname.Text + "','" + Convert.ToDateT ime(dtpentrydat e.Text) + "')";

    Please any one help me.

    Thanks In advance.
  • nbiswas
    New Member
    • May 2009
    • 149

    #2
    Solution to Date time datatype problem in c#.net in windows application

    Use SET DATEFORMAT dmy; in your Stored Proc.

    You may refer to SET DATEFORMAT (Transact-SQL)
    for more info.


    Hope this helps

    Comment

    Working...