I have got a script working to upload files (such as word docs) into a sql server database, but im struggling on creating a asp.net page to download them...
Im using this at the moment:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim conSql as New SqlConnection(ConfigurationSettings.AppSettings("strCon"))
Dim strSql As String = "SELECT * FROM tblFileUpload WHERE idFileUpload = 10;"
Dim oCmd As New SqlCommand(strSql, conSql)
conSql.Open()
Dim dr As SqlDataReader = oCmd.ExecuteReader()
dr.Read()
Response.ContentType = dr.Item("strContentType")
Response.BinaryWrite(dr.Item("binAttachment"))
conSql.Close()
End Sub
</script>
But it outputs all the binary data into the browser window rather than letting you download the file... Can anyone help??
Thanks
- Carl S