Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 13th, 2004, 04:33 PM
Registered User
Join Date: May 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ado Image problem

Hi, EveryBody,

I want to display pictures stored in a database. First I use the following code(VB6) to save the picture to the database:

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim stream As New ADODB.stream
Set cnn = New Connection

cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\test.mdb;"
cnn.CursorLocation = adUseClient
Set rst = New Recordset
rst.ActiveConnection = cnn
rst.Open "t1", cnn, adOpenKeyset, adLockOptimistic
rst!p_name = "dd"
stream.Type = adTypeBinary
stream.LoadFromFile "H:\pp.jpg"
rst!pic = stream.Read
Set stream = Nothing
and then I use the following code(ASP) to display the image:

Dim cnn
Dim rs
' Clear existing HTTP header info
Response.Expires = 0
Response.Buffer = TRUE

' Set the HTTP header to an image type.
Response.ContentType = "image/JPEG"

cnnPubs=getdbconn() ' the function return the db connection
set rs=server.CreateObject("adodb.recordset")
rs.Open "SELECT FROM t1where id=1",cnn

Response.BinaryWrite rst("pic")

and I use <img SRC="getImage.asp"> to show the image.
the first(vb) code works well.
but I alway can not display the image, I just got a image like red X.

please help me to solve the problem.

Thanks a lot!!!



Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO.Net Problem akhilesh_g ASP.NET 2.0 Professional 2 December 18th, 2007 05:33 AM
ADO DB problem. KalliMan2 Visual C++ 7 March 27th, 2006 02:00 AM
ADO.NET(Retrieve image from databse) lovelyphor ADO.NET 1 October 9th, 2004 10:17 AM
ADO.NET Problem lakmaldp ADO.NET 1 July 15th, 2004 01:58 AM
ADO.NET Problem dfb78 Classic ASP Databases 1 June 5th, 2003 05:01 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.