473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Download a File from a SQL Server image column

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
Common.DataAccess.SPParameter("@DOCUMENT_ID",
CInt(CStr(Me.GetFieldValue("DOCUMENT_ID", Nothing).Value)))
Dim ds As DataSet =
Common.DataAccess.DataAccessFunctions.Execute_Stor ed_Procedure("DOCUMENT_BINARY_GET",
oParam)

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())
context.Response.Clear()

context.Response.AddHeader("Content-Disposition",
String.Format("attachment; filename={0}",
Replace(CStr(ds.Tables(0).Rows(0).Item("FILE_NAME" )), ".",
Now.ToFileTime.ToString & ".")))
context.Response.BinaryWrite(byteField)
Context.Response.ContentType =
CStr(ds.Tables(0).Rows(0).Item("CONTENT_TYPE"))
Context.Response.Flush()
context.Response.End()
End If

End Sub

Much appreciated for any help

Jul 21 '05 #1
0 883

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Aaron | last post by:
On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(privacy protection). When a visitor clicks on the link I want them to see my_vacation_pic.jpg (fetch realname from database) is...
6
by: Glenn Owens | last post by:
As a "newbie" to Javascript I need some help with my latest problem... I have a number of image files that have been pre-selected by the user for downloading. I'd like to be able to have the user...
5
by: Dave | last post by:
Hi all, Apologies if this is the wrong group. I have done a search on google but my keywords are probably no good. What I want to do is to display a list of data in a datagrid (which I have...
8
by: kieran | last post by:
Hi, I want to download an image from the web and save it locally. I have spent all day messing about with this and am still no where. We have a firewall so i use the below code. I know it...
5
by: Baren | last post by:
Hi! I am using impersonate="true" to upload and download files from a network share. I have created common users on both the webserver and the file server. The user has permission to the...
5
by: Bala | last post by:
Hi Is it possible to user can download the pdf files thru my webserver which the files are stored on different local machine on network. like my aspx page contain href links to those files. i...
5
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
0
by: bananularstyle | last post by:
Hi everyone, This is an issue I have been picking away at for the past two weeks and am running short of ideas. :-\ I am writing an ASP page that allows a user to open/save a tif image stored on...
7
by: Sheldon Glickler | last post by:
I have a set of jpg files on a page. I want to give the user the option to downloadd all of them at once. What is the code to do that? It must exist because many times users are presented with a...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.