Loading Image from database

bharanidharanit

Well-known member
Joined
Dec 8, 2008
Messages
53
Location
India
Programming Experience
1-3
Hello,
I used the below coding to store an image into the database.
VB.NET:
   1.
      lblImagePath.Text = ImageUpload.PostedFile.FileName
   2.
      ImageUpload.PostedFile.SaveAs(lblImagePath.Text)
   3.
      Dim mbytes() As Byte = System.IO.File.ReadAllBytes(lblImagePath.Text)
   4.
      Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\database\db.mdb;Persist Security Info=False")
   5.
      Dim cmd As New OleDbCommand("insert into ImageTable values (@Image)", cn)
   6.
      cmd.Parameters.Add("@Image", OleDbType.Binary, mbytes.Length).Value = mbytes
   7.
      cn.Open()
   8.
      cmd.ExecuteNonQuery()
   9.
      Response.Write("Image load Success")
  10.
      cn.Close()
Now how to load this image into an image box?
 
Back
Top