Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to upload softwares and documents using V.B and save it on sql database and be able to retrieve it for downloading purposis. please help if its possible
Posted
Comments
vahid_gian 16-Aug-11 5:34am    
what exactly you need?
You want to use it for updating your client software or what??

1 solution

Yes, it's possible - the FileUpload control doesn't care what type of data it uploads, it just passes it though as a binary stream. You can save this to the IMAGE or VARBINARY field of an SQL database (since these are the only ones capable of holding more than 8K bytes - in the latter case define it as VARBINARY(MAX))
Then just save them to the database:
C#
byte[] data = myFileUpload.FileBytes;
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    SqlCommand com = new SqlCommand("INSERT INTO myTable (data) Values (@DT)", con);
    com.Parameters.AddWithValue("@DT", data);
    com.ExecuteNonQuery();
    }
 
Share this answer
 

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