Sousa Pambo

Sousa Pambo

  • NA
  • 92
  • 24k

Get image/picture from database

Mar 16 2014 3:29 PM
Hi fellow, I need your help. I don't get the error on this
 
my Crud
 
public Image GetFuncImage(UIL.frmFunc FC, string lbFuncID)
{
string sql = "select funcFoto from FuncData where nomeFunc ='" + lbFuncID + "'";
using (SqlConnection myconn = new SqlConnection(con.stringConexaoRH()))
{
try
{
myconn.Open();
using (SqlCommand comand = new SqlCommand(sql, myconn))
{
using (SqlDataReader dtreader = comand.ExecuteReader())
{
if (dtreader.Read())
{
Byte[] bytePicData = dtreader["funcFoto"] as byte[] ?? null;
if(bytePicData != null)
{
MemoryStream mstream = new MemoryStream(bytePicData);
FC.pbFuncFoto.Image = System.Drawing.Image.FromStream(mstream);
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);
}
}
}
}
}
}
catch (Exception ex)
{
return FC.pbFuncFoto.Image = RH_2013.Properties.Resources.icon_employer;
}
}
return FC.pbFuncFoto.Image = RH_2013.Properties.Resources.icon_employer;
}
}
__________________________________________________________________________________________
my Event
 
private void pbFuncFoto_Click(object sender, EventArgs e)
{
this.pbFuncFoto.Image = FuncDal.GetFuncImage(this, this.lbIdFunc.Text);
}
 __________________________________________________________________________--
 
Where I'm wrong here.... 
 

Answers (13)