I am having trouble getting images to display on an application I am trying to build. I have my images stored in a directory and then have a pointer in sql to those files. I want to display the photo associated with the particular record in my windows form but I cannot seem to make it happen. Any advice or code samples would be appreciated. Thanks.

Displaying an image stored as a pointer in a SQL table.
Rimoldi
Judoshiai
I changed it to match my data but I cannot get VB to run it. Here is what I put.
Dim MyReader As OleDb.OleDbDataReader
Dim MyCommand As New OleDB.OleDbCommand("SELECT Image FROM DataInfo")
MyReader = MyCommand.ExecuteReader
MyReader.Read()
Me.PictureBox1.ImageLocation = Image.FromFile(MyReader("Image"))
It tells me that a Declaration is needed for MyReader and that there is a syntax error for Me. I have tried several different things but none seem to correct it.
Aditi A.Kirkole
Nick Bowling
Are you having trouble reading the database, or opening an image file
(I presume your 'pointer' is actually a filename/path to the image).
iStalker
John McPherson
That's why I said it was "PSEUDO" code...
1. The command object will need the connection object assigned
2. The connection object will need the connection string assigned
3. The connection will have to be opened prior to executing the command
4. After you have retrieved the field info be sure to close the connection
Dim MyReader As OleDb.OleDbDataReader
Dim MyCommand As New OleDB.OleDbCommand("SELECT Image FROM DataInfo")
Dim MyCOnnection as New OledbConnection(TheConnectionString)
MyCommand.Connection = MyConnection
MyConnection.Open
MyReader = MyCommand.ExecuteReader
MyReader.Read()
Me.PictureBox1.ImageLocation = Image.FromFile(MyReader("Image"))
MyCOnnection.close()
Vignesh Kannappan
pseudo code:
Dim MyReader As OleDbDataReader
Dim MyCommand As New OleDbCommand("Select ImagePathField From MyTable") MyReader = MyCommand.ExecuteReader MyReader.Read() Me.PictureBox1.ImageLocation = MyReader("ImagePathField")or
Me.PictureBox1.Image = Image.FromFile(MyReader("ImagePathField"))