By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

Download a File from a SQL Server image column

P: n/a
I'm trying to download a file in the click event of a linkbutton. I've
got working code for this, however, the 'Open' function of the dialog
that pops up doesn't work. The 'Save' does, and I can successfully
open the file that was saved.
Here's my code:
Private Sub Document_Click(ByVal source As Object, ByVal args As
System.EventArgs) Handles lnkBtnDocument.Click

Dim oStreamReader As System.IO.StreamReader

'internal method to cast a SQL stored procedure parameter
Dim oParam As New
CInt(CStr(Me.GetFieldValue("DOCUMENT_ID", Nothing).Value)))
Dim ds As DataSet =
Common.DataAccess.DataAccessFunctions.Execute_Stor ed_Procedure("DOCUMENT_BINARY_GET",

If Not ds.Tables.Count < 1 AndAlso Not
ds.Tables(0).Rows.Count < 1 Then

Dim byteField() As Byte =
CType(ds.Tables(0).Rows(0).Item("DOCUMENT"), Byte())

String.Format("attachment; filename={0}",
Replace(CStr(ds.Tables(0).Rows(0).Item("FILE_NAME" )), ".",
Now.ToFileTime.ToString & ".")))
Context.Response.ContentType =
End If

End Sub

Much appreciated for any help

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.