Publish date: 2004-08-10

Getting picture from database (VB)

<html>
 <title>Picture Test</title>
 <body>
  <p>This is IBProvider logo.<br><br> <img src="get_picture.asp"></p>
 </body>
</html>

get_picture.asp

<%
 Dim Conn
 Dim Cmd
 Dim Row
 Set Conn = Server.CreateObject("ADODB.Connection")
 Set Cmd  = Server.CreateObject("ADODB.Command")'

 Conn.Provider = "LCPI.IBProvider.3"

 Conn.Open "location=localhost:e:\database\pic_db1.gdb;ctype=win1251", "sysdba", "masterkey"

 Conn.BeginTrans

 Cmd.ActiveConnection = Conn
 Cmd.CommandText = "select data from pictures"

 Set Row = Cmd.Execute

 If Not Row.Eof Then
   Response.ContentType = "image/gif"
   Response.BinaryWrite Row("data")
   Response.ContentType = "text/HTML"
 End If

 Conn.CommitTrans
%>