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

Unable to download BLOB IMAGE using ODBC

P: 1
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 SQL Server.

The user triggers the download by clicking a hyperlink which loads getAttachment.asp (code listed below). GetAttachment.asp connects to SQL Server through an ODBC and attempts to download the specified tiff using BinaryWrite(). It looks like the file being downloaded is very close in size to the image but, not a tiff.

Are there any procedures I may be missing when attempting to retrieve the image?
Is a byte array necessary when trying to pass an image type from a table to the web browser?

Any suggestions would be greatly appreciated.


images.table
Image ID(int): att_id
Image Blob(image): ATTACHMENT

Image filename:QM1BM.TIF
---------------------------------------------------------------------------------------

<%
dim objConn, objRS, strSQL, strConnection
dim PubID
PubID = 3751

Response.Clear
Response.Expires = -1
Response.ContentType ="image/tiff"

set objConn=server.CreateObject ("ADODB.connection")
objConn.ConnectionString="DSN=DPA_Database;uid=use r_id;pwd=pwd;DATABASE=DPA_Database;APP=ASP script;NETWORK=DBMSSOCN;TABLE=dbo.DPA_IMAGES"
source=DOUG
objConn.Open

set objRS=server.CreateObject ("ADODB.Recordset")
strSQL= "SELECT * FROM dbo.DPA_IMAGES WHERE att_id='"& PubID &"'"
set objRS=objConn.Execute(strSQL)

'Let the browser know the file name'
Response.AddHeader "Content-Disposition", "attachment;filename='"& (objRS("R1_ID")) &"'.tiff"
'Let the browser know the file size'
'Response.AddHeader "Content-Length", "500000"'
Response.BinaryWrite (objRS("ATTACHMENT"))
Response.End

objRS.Close
objConn.Close
set objConn = nothing
set objRS = nothing
%>
Jan 24 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.