469,306 Members | 1,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Show image from SQL Image Field ?

Bob
Hello:

I've tried showing an image field from an MS SQL Server 2000 image field on
an ASP page but All I get is this
http://http://new.confectioneryhouse...free/about.asp

I added the content type and followed the many postings but no joy.

Here is my code. I'm using 2 pages.

(Page 1) blob.asp

<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_blob_STRING
Recordset1.Source = "SELECT AboutPic FROM Elizabeth.GF_AboutUs"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Response.contentType = "image/jpg" 'Recordset1.Fields("AboutPic") <---Tried
both methods
size = Recordset1.Fields("AboutPic").ActualSize
blob = Recordset1.Fields("AboutPic").GetChunk(size)
Response.binarywrite(blob)
%>

(Page 2 Show the Image)

<%
Dim urlString
urlString = "?" & Request.QueryString
%>

<% Another rs to show other information as text from the same table %>

<body>
<img src="blob.asp<%=urlString%>" width="194" height="256">
</body>

TIA

Bob
Jul 19 '05 #1
2 8250
Well that's a nice rendition of ASCII of a binary file. Use
Response.BinaryWrite

--
George Hester
__________________________________
"Bob" <No********@adelphia.net> wrote in message
news:uM*************@TK2MSFTNGP10.phx.gbl...
Hello:

I've tried showing an image field from an MS SQL Server 2000 image field on an ASP page but All I get is this
http://http://new.confectioneryhouse...free/about.asp

I added the content type and followed the many postings but no joy.

Here is my code. I'm using 2 pages.

(Page 1) blob.asp

<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_blob_STRING
Recordset1.Source = "SELECT AboutPic FROM Elizabeth.GF_AboutUs"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Response.contentType = "image/jpg" 'Recordset1.Fields("AboutPic") <---Tried both methods
size = Recordset1.Fields("AboutPic").ActualSize
blob = Recordset1.Fields("AboutPic").GetChunk(size)
Response.binarywrite(blob)
%>

(Page 2 Show the Image)

<%
Dim urlString
urlString = "?" & Request.QueryString
%>

<% Another rs to show other information as text from the same table %>

<body>
<img src="blob.asp<%=urlString%>" width="194" height="256">
</body>

TIA

Bob

Jul 19 '05 #2
Bob
I use Response.binarywrite and I get this:

http://website.bestsytes.net/untitled.asp
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dave | last post: by
5 posts views Thread by canajien | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.