Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
"String or binary data would be truncated. The statement has been terminated." Please explain about this exception.
Posted
Updated 5-Feb-20 21:26pm

This exception occures when your datatype,size does not match with database field attributes.
See Discussion
 
Share this answer
 
Comments
Mehdi Gholam 8-Dec-11 2:18am    
5'ed
uspatel 8-Dec-11 2:30am    
thanks..
James McCullough 1-May-16 2:27am    
LOVE IT! Simple and to the point!
Member 12625053 22-Jul-16 2:56am    
I have set my fields datatype as varBinary(MAX). it is uploading .txt file but giving exception to any other fileType
Member 13607841 5-Feb-18 7:05am    
thanks
String or binary data would be truncated Error suggests your Datatype in Database is smaller than inserted value.


1. Increase datatype length or decrease length of value before inseration.
 
Share this answer
 
Comments
kinjal b patel 11-Oct-12 8:42am    
thanks buddy ..........!
Member 14788228 5-Apr-20 13:47pm    
the size of the datatype is same as the attribute in the database. and i am inserting less datatype than i put in max size. and still i am facing on this error.
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
 
Comments
Member 14074976 16-Jun-19 22:18pm    
Thank you sir now know that issue may error thanks dost
Member 14944961 17-Oct-20 7:54am    
hi
when user store data at that time size of data type is less as compared to required data type size then it gives such kind of error solution to increase your data type size...
 
Share this answer
 
Comments
[no name] 3-Mar-13 11:50am    
Exactly what the other solutions told him in Dec 2011. How does your solution in any way provide any additional information on this question?
bramh_dwivedi 28-Apr-13 13:37pm    
how i can handle this exception String or binary data would be truncated.\r\nThe statement has been terminated."

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