ev66
Member
- Joined
- Apr 2, 2007
- Messages
- 9
- Programming Experience
- Beginner
Hi,
I have images stored in a mysql table in BLOB format. How do i show the pic in a PictureBox ?
PictureBox1.Image = myCommand.ExecuteScalar() does not work.
The connection and SELECT is ok , its just the last bit i'm stuck on.
Here is my code-
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myData As New DataTable
Dim SQL As String
SQL = "SELECT pic FROM mytable WHERE id=2"
conn.ConnectionString = "server=" & text1.Text & ";" _
& "user id=" & text2.Text & ";" _
& "password=" & text3.Text & ";" _
& "database=mymedia"
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
myCommand.Connection = conn
myCommand.CommandText = SQL
myAdapter.SelectCommand = myCommand
myAdapter.Fill(myData)
PictureBox1.Image = myCommand.ExecuteScalar()
dgvStatus.DataSource = myData
Thank you
I have images stored in a mysql table in BLOB format. How do i show the pic in a PictureBox ?
PictureBox1.Image = myCommand.ExecuteScalar() does not work.
The connection and SELECT is ok , its just the last bit i'm stuck on.
Here is my code-
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myData As New DataTable
Dim SQL As String
SQL = "SELECT pic FROM mytable WHERE id=2"
conn.ConnectionString = "server=" & text1.Text & ";" _
& "user id=" & text2.Text & ";" _
& "password=" & text3.Text & ";" _
& "database=mymedia"
Try
conn.Open()
Catch myerror As MySqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
End Try
myCommand.Connection = conn
myCommand.CommandText = SQL
myAdapter.SelectCommand = myCommand
myAdapter.Fill(myData)
PictureBox1.Image = myCommand.ExecuteScalar()
dgvStatus.DataSource = myData
Thank you