Hello,
I used the below coding to store an image into the database.

lblImagePath.Text = ImageUpload.PostedFile.FileName
        ImageUpload.PostedFile.SaveAs(lblImagePath.Text)
        Dim mbytes() As Byte = System.IO.File.ReadAllBytes(lblImagePath.Text)
        Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\database\db.mdb;Persist Security Info=False")
        Dim cmd As New OleDbCommand("insert into ImageTable values (@Image)", cn)
        cmd.Parameters.Add("@Image", OleDbType.Binary, mbytes.Length).Value = mbytes
        cn.Open()
        cmd.ExecuteNonQuery()
        Response.Write("Image load Success")
        cn.Close()

Now how to load this image into an image box?

Protected Sub imgUpload_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles imgUpload.Load
        Dim cmd As New OleDbCommand("select ImageData from ImageTable where ImageName='menu.JPG'", DataConn)
        DataConn.Open()
        Dim dr As OleDbDataReader
        cmd.ExecuteNonQuery()
        dr = cmd.ExecuteReader
        dr.Read()
        Response.BinaryWrite(dr("ImageData"))
        dr.Close()
    End Sub

I used the above and the image in displayed in imagebox, but in the page i am getting the as string as below.

if your image size is larger or you want to display more images then use generic handler, pass Image id to it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.