Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 date time

Author  Topic 

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-09-08 : 08:42:30
How to send datetime to database from front end.

I experienced this error

String or binary data would be truncated.
The statement has been terminated.

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-09-08 : 08:50:28
And this error in my back end

Error converting data type nvarchar to datetime.
Go to Top of Page

DaleTurley
Yak Posting Veteran

76 Posts

Posted - 2010-09-08 : 09:09:16
What is the front end written in?

In .net insert a DateTime object.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-08 : 09:14:58
Post the code you used

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-09-08 : 09:24:13
cmd.Parameters.Add("@start_date", SqlDbType.DateTime).Value =Convert.ToDateTime(start_date.Trim());

First thing i din't convet to date time...And varchar(20) is no enough for my data ..
I cleared my error thanks for the kind response Madhivanan & DaleTurley
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-08 : 09:26:03
quote:
Originally posted by jafrywilson

cmd.Parameters.Add("@start_date", SqlDbType.DateTime).Value =Convert.ToDateTime(start_date.Trim());

First thing i din't convet to date time...And varchar(20) is no enough for my data ..
I cleared my error thanks for the kind response Madhivanan & DaleTurley


Are you using varchar(20) for storing dates? If so, you should use proper DATETIME datatype

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jafrywilson
Constraint Violating Yak Guru

379 Posts

Posted - 2010-09-08 : 10:40:15
No no i am using detetime for date ..
For mail_id i used varchar(20)..So only error occured
Go to Top of Page
   

- Advertisement -