This is an example to show blob images from the database, you can modify it to offer the file for download instead of showing the image (id is the image file id in the database):
void CreateImage(string id)
{
// Connection string is taken from web.config file.
SqlConnection _con = new SqlConnection(
System.Configuration.ConfigurationSettings.AppSettings["DB"]);
try
{
_con.Open();
SqlCommand _cmd = _con.CreateCommand();
_cmd.CommandText = "select logo from" +
" pub_info where pub_id='" +
id + "'";
byte[] _buf = (byte[])_cmd.ExecuteScalar();
// This is optional
Response.ContentType = "image/gif";
//stream it back in the HTTP response
Response.BinaryWrite(_buf);
}
catch
{}
finally
{
_con.Close();
}
}