When the image exists at the database , It shows correctly at pictureBox.
If the image doesn't exist, it shows error.
The Code is Here !
Private Sub gdCompany_CellClick_1(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gdCompany.CellClick
btnSave.Text = "ျပင္ရန္"
picCompanyLogo.Visible = True
txtCompanyName.Text = gdCompany.CurrentRow.Cells(1).Value.ToString()
txtDescription.Text = gdCompany.CurrentRow.Cells(2).Value.ToString()
txtPhoneNo.Text = gdCompany.CurrentRow.Cells(3).Value.ToString()
txtFaxNo.Text = gdCompany.CurrentRow.Cells(4).Value.ToString()
txtEmail.Text = gdCompany.CurrentRow.Cells(5).Value.ToString()
txtWebsite.Text = gdCompany.CurrentRow.Cells(6).Value.ToString()
ddlBankName.SelectedValue = Convert.ToInt32(gdCompany.CurrentRow.Cells(7).Value.ToString())
ddlBankBranch.SelectedValue = Convert.ToInt32(gdCompany.CurrentRow.Cells(8).Value.ToString())
txtBankAccountNo.Text = gdCompany.CurrentRow.Cells(9).Value.ToString()
txtAddress.Text = gdCompany.CurrentRow.Cells(10).Value.ToString()
Try
Dim imageData As Byte() = DirectCast(gdCompany.CurrentRow.Cells(15).Value, Byte())
Dim newImage As Image
Using ms As New MemoryStream(imageData, 0, imageData.Length)
ms.Write(imageData, 0, imageData.Length)
newImage = Image.FromStream(ms, True)
End Using
picCompanyLogo.Image = newImage
Catch ex As Exception
MessageBox.Show(ex.ToString())
txtCompanyName.Focus()
End Try
End Sub