views:

109

answers:

2

Hi:

    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

A: 

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

Babar
+1  A: 

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

INinjaAndy
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.
INinjaAndy