can anybody tell how to fetch image from database(access) to the
visual basic picture box control. the code i have been using is as
below but it gives me invalid paramter error....
Dim connection As New OleDb.OleDbConnection()
Dim cmd As New OleDb.OleDbCommand()
cmd.CommandText = "select ID,Name,Description,Image from
MASTER where ID like '" & Trim(cmbID.Text) & "'"
cmd.Connection = connection
Dim myReader As OleDb.OleDbDataReader
cmd.CommandType = CommandType.Text
openOLEDBconnection(SQL_CONNECTION_STRING, connection)
myReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
While myReader.Read()
txtId.Text = myReader(0)
txtName.Text = myReader(1).ToString()
txtDescription.Text = myReader(2).ToString()
If Not IsDBNull(myReader(3)) Then
Try
Try
Dim a(myReader.GetBytes(3, 0, Nothing, 0,
Integer.MaxValue) - 1) As Byte
myReader.GetBytes(3, 0, a, 0, a.Length)
Dim b As New MemoryStream(a)
With pbImage
.Image = image.FromStream(b)
.SizeMode =
PictureBoxSizeMode.CenterImage
.BorderStyle = BorderStyle.Fixed3D
End With
Catch exp As Exception
MsgBox(exp.Message)
End Try
Catch exp As System.InvalidCastException
MsgBox(exp.Message)
End Try
End If
End While
myReader.Close()