Tuesday, March 6, 2012

Add New Record into table

Hi , All
I default value in textbox for show now date and I used to method

txtDate.Text = Now.ToShortDateString

It's have problem when I want to add new record in table

I get error message "The statement has been terminated. String or binary data would be truncated. "

and I set type in database is char length 10 ,I can't set type is datetime because in SQL Server fix type datetime

It's have length 8 but 8 length it's not enough for default value
Please help me
Thanks
Nisarat

First use DateTime.Now.ToShortDateString
Secondly use 'yyyy-MM-dd' eg. '2005-06-01'(notice the single quote ' ) format while inserting data.
|||

Hi, dinuj

I set type of field date is datetime and set default value "dd/mm/yyyy" but I get error message "Error validating the default for column "datekey""
Thanks
Nisarat

|||Do mean to say that you are trying to set a default date for the coloumn datekey
|||

Hi,Dinuj

yes ,I trying set type of field DateKey is DateTime type but ,in SQLServer it's 8 char only and I will trying to defaulf value in this field but It's can not
Thanks
Nisarat

|||

Nisarat wrote:

Hi,Dinuj

yes ,I trying set type of field DateKey isDateTime type but ,in SQLServer it's 8 char only and I willtrying to defaulf value in this field but It's can not
Thanks
Nisarat


Is your DateKey column is of DateTime type? DateTime is 8 bytes widenot 8 chars. Are you using Enterprise Manager ? If yes then clickon Default value and set the default date to whatever you want in thisformat 'yyyyMMdd' . For example for today '20050606'

No comments:

Post a Comment