An error occurred while updating the entries.String or binary data would be truncated.\r\nThe statement has been terminated.

1376
Views
1
Answers

I am trying to Insert a string into a varchar field in SQL database from my MVC3 apllication using Linq to Entities. I get this error

"String or binary data would be truncated.\r\nThe statement has been terminated."

Stack Trace:

at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
   at
System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
   at
System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
   at
System.Data.Objects.ObjectContext.SaveChanges()
edit | flag
Sam Bells
Asked on: Feb 12, 2012 at 7:40AM

1 Answers

130
2
130

You get this error because the data you are updating / inserting into the SQL varchar(n) field may be larger than it was declared. For example: If you specify varchar(50) and try to insert data more than 50 characters length you will end up in this error.

edit | flag
Gokul A
Answered on: Feb 14, 2012 at 3:04AM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags