0

I am using Asp.Net MVC. in my project while uploading PDF file we convert the PDF file into byte then store it in DB. but i got the following exception.

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

Can any one solve this issue.I got the exception righ here

context.SubmitChanges();

Thanks: Suresh

2
  • Please provide the details about the database, which dbms you are using and what is the data type and length of the column in which you are storing the file. Commented Jun 19, 2009 at 10:24
  • that looks like a SQL server error message Commented Jun 19, 2009 at 10:27

2 Answers 2

1

Just change the size of your field, try varbinary(MAX).

Sign up to request clarification or add additional context in comments.

1 Comment

Does this answer it for you? Babar is correct that the database field used to store the file as a byte array is too small, sql server is throwing the 'binary data would be truncated' exception on insert. You should increase the field size to something that you know can accommodate the data you are trying to put in or just set it to MAX.
0

This is most probably because the code attempted to insert more data/bytes in your database column than its defined size.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.