Display image on pictureBox using the image path stored on DB

Solved/Closed
mikeoe2003 Posts 25 Registration date Thursday November 1, 2012 Status Member Last seen March 27, 2014 - Nov 21, 2012 at 03:30 AM
 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


2 responses

Zohaib R Posts 2368 Registration date Sunday September 23, 2012 Status Member Last seen December 13, 2018 69
Nov 22, 2012 at 11:55 AM
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.
5
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
0
Amazing
thankyou
0
Thank you sir for this coding I was googling about 2 days for this code.it helped me a lot....:)
0
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
0
add .// as your given path
or..//
0