473,398 Members | 2,393 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,398 software developers and data experts.

Retrieving executables from SQL in ASP.NET

I am using the following code on a page called file.aspx
to retrieve binary files from a SQL db, but if I try to
retrieve a .exe file, it prompts me to download file.aspx
instead of [filename].exe.

<begin code>

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
' Put user code to initialize the page here' --
file.asp --
' Retrieves binary files from the database

Dim dbConn As New SqlConnection
(CCDataConnection.dbConnString)

Response.Buffer = True

' ID of the file to retrieve
Dim ID, fileSize As String
ID = Request.QueryString("id")
fileSize = Request.QueryString("size")

If Len(ID) < 1 Then
ID = 7
End If

' Recordset Object
Dim rs As SqlDataReader
Dim strSql As String
Dim sql As SqlCommand

dbConn.Open()
' opening connection
strSql = "select change_file_name,
change_file_attachment, change_file_content_type from
CHANGE_FILES where change_id_fk = " & _
ID & " AND change_file_size = '" &
fileSize & "'"
sql = New SqlCommand(strSql, dbConn)
rs = sql.ExecuteReader()
If rs.Read() Then
Response.ContentType = rs
("change_file_content_type")
Response.BinaryWrite(rs
("change_file_attachment"))
End If

rs.Close()
rs = Nothing
sql = Nothing
dbConn.Close()
dbConn = Nothing
End Sub

<end code>

Any suggestions?

Thanks,
Greg

Nov 17 '05 #1
0 801

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

Similar topics

9
by: mac | last post by:
when a c program is compiled using 'gcc test.c' 'cannot create c executables is thrown' I cannot able to figure out the problem could anyone help me. Thanks.
20
by: | last post by:
Back in the Old days, I compile a C++ executable, copy the dll's used by this executable to the same folder. Go to another computer, copy that folder locally, double click on the exe file and off...
2
by: ven | last post by:
I have used C# binary formatter to serialize and deserialize a data structure. However, for the same data format( used by the first executable, the same *.CS files), the second executable gives an...
5
by: VJ | last post by:
I have one VB.NET project, that outputs a "Mycomapny.exe" everytime I do a build. But I need it to output 4 different executables everytime I build. How do I archive this. I am looking at the...
0
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
1
by: Water Cooler v2 | last post by:
I have a Windows Service I am writing in C# and a set of, let us say three, other executables written in C# (mostly console applications). I want that the Windows Service must do so every few...
0
by: A W | last post by:
Hello, I am encountering the following scenario while compiling a project under Visual Studio 2005 with the floating point model set as precise. Two executables A and B share a common dll C. ...
4
by: ravit | last post by:
I have built my gdb-6.7.1 yesterday on my AIX 5.3 64 bit machine. my gcc is gcc3.3.2 and tried debugging 64 bit executables generated by gcc, working fine. debugging session ends successfully....
4
by: shirleylouis | last post by:
Hi Ppl, Could anyone help me out with retrieving URL from Clipboard using C#??
6
by: =?Utf-8?B?Q2hhcmxlcyBS?= | last post by:
I have two different executables that I want to build w/ the same source but in 2 different compilers, vs60 and vs2008. I have 2 different configurations w/ different options etc, but I want one...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.