bharanidharanit
Well-known member
Hello,
I used the below coding to store an image into the database.
Now how to load this image into an image box?
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()