1) First create a new column and set it as varbinary(MAX) for the datatype.
2) Use this code to store the file to database:
//Read File to Bytes
FileStream st = new FileStream(<Location of the file>, FileMode.Open);
byte[] fileData= new byte[st.Length];
st.Read(fileData, 0, (int)st.Length);
st.Close();
SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ID",<Reference ID>),
new SqlParameter("@Data",fileData) };
int i = SqlAccessor.ExecuteNonQuery(<ConnectionString>, SqlAccessor.SqlCommandBuilder(new SqlCommand (<Stored Procedure Name>), param), CommandType.StoredProcedure, out retVal);
I've used Application Blocks to simplify data operation.
To Retrieve the data and to be downloaded from an ASP.NET Page:
3) I created a function that returns a byte array with ID as parameter
public static...