Retrieving an image from an access database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miffer
    New Member
    • Jul 2007
    • 2

    #1

    Retrieving an image from an access database

    Hi everyone

    For reasons best known to our IT department, my department is not allowed to use SQL. Instead we have to use Access. No problem there, except we have a need to store images into a database for security reasons. I have now spent over a day and a half trying to crack this. I know it is something to do with stripping the headers from the image held in the database. I did come across an example in c# on this site, but couldn’t convert that code into vb.net.

    My current code behind page looks like this and produces gibberish

    Option Strict Off
    Imports System
    Imports System.Web.UI

    Imports System.Data
    Imports System.Data.Ole Db
    Imports System.Configur ation


    Public Class PublicGuideline List: Inherits Page

    public strImage as string
    Public strConnString as String = ConfigurationSe ttings.AppSetti ngs("Connection String")
    public objConn as New OleDbConnection (strConnString)

    Sub Page_Load(Src As Object, E As EventArgs)
    If Not Page.IsPostBack

    BindData()
    End If
    End sub

    sub bindData()



    strImage = "SELECT * FROM table1 "
    objConn.open

    ' Create & execute OleDbCommand query to return records
    dim ocd as OleDBCommand = New oleDbCommand(st rImage, objConn)
    dim myDataReader as oleDBdatareader

    myDataReader=oc d.executereader ()


    myDataReader.re ad()

    Response.binary Write(myDataRea der.Item("signa ture"))

    objConn.close
    end sub

    end class

    If anyone has a snippet, I would be grateful.
Working...