hi i need help

pts.
Tags:
C
SQL Server
in c#.net we are taking datetime from datetimepicker we are storing datetime into sqlserverdatabase. in sqlserver we are taking datetime datatype. we write code like this: Datetime dt=DateTimePicker1.value; cmd=new sqlcommand("insert into values(date) tablename('"+dt+"')",con); cmd.excutenonqury(); we are seleted date datetimepicker as 19/12/2006 after excuting this one we are getting error like this: conversion of char data type to datetime data type resulted in an out of range datetime value

Answer Wiki

Thanks. We'll let you know when a new response is added.

MSSQL does not recognize day/month/year as a valid date format. It can be reversed to year/month/day or use month/day/year.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • BillElPaso
    you are using European style dates, DD/MM/YYYY and SQL Servert is expecting American style dates MM/DD/YYYY. change the code that looks like ('"+dt+"') to look like ('"+Format(dt,"MM/DD/YYYY")+"') should do the trick.
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: