file upload,All files ,Download,Error

Posted by Raja_89 under C# on 4/16/2013 | Points: 10 | Views : 1089 | Status : [Member] | Replies : 1
1. I have stored datatype to store a uploaded file to varbinary(max) in Sql server 2005 .
It shows an error message

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

What is the datatype used to store all type of files

How can i rid of this
2 how can i download the uploaded file from sql server
File not downloaded in the form of System byte[]..etc

Attached while ask to download


Posted by: lakhansin-22735 on: 6/27/2013 [Member] Starter | Points: 25

To save uploaded file into database

First you have to convert uploaded file into byte format
//convert the uploaded file into bytes

byte[] file = ConvertFiletoByte(UploadedFile);

Second, save file as a Image yes this will be hold by a Image Sql server DataType field
//Pass file as a parameter

command.Parameters.Add("file", SqlDbType.Image);
command.Parameters["file"].Value = file;

Lakhan Singh
Tech Lead
BeyondKey System Pvt. Ltd.
Indore, M.P.

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response