Display image on pictureBox using the image path stored on DB [Solved/Closed]

Posts
25
Registration date
Thursday November 1, 2012
Last seen
March 27, 2014
- - Latest reply:  umesh - Feb 9, 2017 at 04:11 AM
Hello,
when I run a select query I wan the the picture box on the form to display image of the File path stored in the database table. please I need help


See more 

2 replies

Best answer
Posts
2403
Registration date
Sunday September 23, 2012
Last seen
December 13, 2018
644
5
Thank you
Hi mikeoe2003,

Create a form with the controls shown in the below mentioned image:

http://img43.imageshack.us/img43/4668/formsh.jpg

Create a Database with the name Databasemikeoe2003PictureApplication.mdb (see the image below for the design of the Database):

http://img846.imageshack.us/img846/6905/databaseb.jpg

Paste the below mentioned code in the Click event of ButtonSelect:

Dim cnn As New OleDb.OleDbConnection
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Databasemikeoe2003PictureApplication.mdb;"

If cnn.State = ConnectionState.Open Then
cnn.Open()
End If
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Tablemikeoe2003PictureApplication WHERE Id = " & TextBoxPictureID.Text, cnn)
Dim dt As New DataTable
da.Fill(dt)
Me.TextBoxPictureFilePath.Text = dt.Rows(0).Item("PicturePath")
cnn.Close()

PictureBox1.Image = System.Drawing.Bitmap.FromFile(TextBoxPictureFilePath.Text)

Run the application and check for the results.

Do reply with results.

Say "Thank you" 5

A few words of thanks would be greatly appreciated. Add comment

CCM 4337 users have said thank you to us this month

Superb. I was puzzled for this.Found many option but not worked even complicated also
But you done the superb job. Heads off to you
quite smile
Thank you soo much
Amazing
thankyou
Thank you sir for this coding I was googling about 2 days for this code.it helped me a lot....:)
0
Thank you
thanks for this help
but my picture can display only when i copy full path from folder, but when i use it the datagridview by getting pic name from datagridview, it becomes error.

pls help more
add .// as your given path
or..//