Dear Sir,
SQL Table employees has data as follows
sno--name----img-----img_path
1-----A----Binary---D:\C2009\BITMAPS\PICT.JPG
2-----B----Binary---D:\C2009\BITMAPS\eric.JPG
Now I want to display picture in picturebox1.
To do this I use this codes, but it does not display picture
on this line: Dim arrPicture() As Byte = CType(dt2.Rows(0)("img_path"), Byte())
it shows this message, please help
Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.
str2 = "select * from employees where sno =" & Val(Me.TextBox1.Text)
cmd2 = New SqlClient.SqlCommand(str2, con)
da2 = New SqlClient.SqlDataAdapter(cmd2)
dt2 = New DataTable
da2.Fill(dt2)
If (dt2.Rows.Count >= 1) Then
Me.TextBox2.Text = dt2.Rows(0)("name")
Me.TextBox3.Text = dt2.Rows(0)("city")
Me.TextBox4.Text = dt2.Rows(0)("phone")
Dim arrPicture() As Byte = CType(dt2.Rows(0)("img_path"), Byte())
Dim ms As New MemoryStream(arrPicture)
With PictureBox1
.Image = Image.FromStream(ms)
.SizeMode = PictureBoxSizeMode.StretchImage
.BorderStyle = BorderStyle.Fixed3D
End With