I want a code to upload a ms word file and store it in sql table.I need this very urgently for my project in asp.net(vs 2003)

:confused: anybody help me plzzzzzzzzz :confused:

12 Years
Discussion Span
Last Post by web developer

Hi ,
you can do that by simply converting any file to an array of bytes - bytes[] (in c#) or bytes() (in vb.net) .
you can add an HTML control ( file )-which browses on file name - and let its name file_upload , right click and selct "run as server control" to use it in the c# or vb.net code.

in C#
int len=file_upload.PostedFile.ContentLength;
byte[] bData=new byte[len];
//fill array of bytes

Note the field type of database (in Sql server) should be image .
You must send the value by a parameter and the value of the parameter will be the array filled .

param1.value=bData ;
then executeNonquery(); will insert the file .

I hope i could help you .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.