mySQL Blob images help

Discussion in 'C#' started by StealthRT, Apr 2, 2009.

  1. #1
    Hey all, i am trying to figure out how to go about loading some images from my database. I have been able to accomplish this with only one image, however. I am looking to loop thought the database and display all images that the query looks for..

    Here is my current code:
    
    Pic.asp page
    
    <%
    Dim oConnection
    Dim oRecordset
    Dim Sql  
      	
    	Response.Expires = -10
    	Response.Buffer = True
    	Response.Clear
    
      	Set oConnection = Server.CreateObject("ADODB.Connection")
    	Set oRecordset = Server.CreateObject("ADODB.Recordset")
    	
    	oConnection.Open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=nextbowluser.com; PORT=3306; DATABASE=xxxxx; USER=xxxx; PASSWORD=xxxxxxx; OPTION=3;"
    	Sql="select CoupPicVoid from coupbook"
    	oRecordset.Open Sql, oConnection,3,3
      
     	do until oRecordset.eof
    		Response.ContentType = "image/jpeg"
    		Response.BinaryWrite oRecordset("CoupPicVoid")
    		oRecordset.movenext
    	loop
      
      	oRecordset.Close
    	oConnection.Close
    	Set oRecordset = Nothing
    	Set oConnection = Nothing
    %>
    
    Code (markup):
    
    testpic.asp
    
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <img src="pic.asp">
    </body>
    </html>
    
    Code (markup):
    As you can tell, the <img src="pic.asp"> displays the image that the database is finding. But it only displays one pic. What can i do in order to display all the images that the query finds?


    Thanks for your time,
    David
     
    StealthRT, Apr 2, 2009 IP
  2. prasnasmile

    prasnasmile Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I thing this link will help u check this out.

    http://aspxjavascriptdoubts.blogspot.com/search/label/how%20to%20add%20and%20retrive%20images%20from%20database
     
    prasnasmile, Apr 3, 2009 IP