Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have got a database and i am querying/ inserting via entity framework


I've trying to insert a record into a table and it is giving me the error of "string or binary data would be truncated".


By trial and error, I found the problem field and expanded it in the database and also refreshed my edmx file, i.e. completely deleting all entities within and adding the tables again



I'm still getting the same error, even though I'm 100% certain that the column is now easily big enough.


Can anyone suggest how I can resolve this?
Posted
Comments
Aravindba 10-Mar-14 23:28pm    
can u post ur insert query and table schema in which going to insert,i mean fields and datatype in the table

its a simple error

causes: the size of the column exceeded

suppose if u create a column with varchar(2)

and if u try to insert 'asdasdasd' then u get this error.

now what u do is

change the datatype varchar(**) to varchar(max) now u wont get this error this applies to all datatypes.
 
Share this answer
 
Hi,
Its the error because of data-type and what the size you are passing for inserting data to that field.Suppose i have declared a field named name varchar[20] and i am trying to inserting name of more than 20 characters then i will get an error like "String or binary data would be truncated". So please check all the field.Hope this will work.If not let me know about the error.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900