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....
VulpesPosted Mar 19, 2014, 10:01 AM
Sousa PamboPosted Mar 20, 2014, 9:14 AM
DONE! Thank u very much, its working.
VulpesPosted Mar 19, 2014, 7:19 PM
I don't understand why SqlDbType can't be found as it's an enum in the System.Data namespace.
You must have the following using directive in your file:
using System.Data;
because otherwise SqlConnection and SqlCommand couldn't be found either.
Sousa PamboPosted Mar 19, 2014, 5:28 PM
sqlBuilder.Append("funcFoto=@Pic,"); don't missing something in this line like.....this?
sqlBuilder.Append("funcFoto='"+@Pic +"',"); (its not an error.)
cm.Parameters.Add("@Pic", SqlDbType.Image).Value = ms.ToArray();
- Error "doesn't exist in the current context"
Please help on this
Munesh SharmaPosted Mar 19, 2014, 7:58 AM
Sousa PamboPosted Mar 19, 2014, 7:33 AM
Help me to see the way I save it maybe something is wrong
public void newFuncMax(UIL.frmFunc Fc, string idLb)
{
System.Text.StringBuilder sqlBuilder = new System.Text.StringBuilder();
sqlBuilder.Append("Update FuncData set ");
sqlBuilder.Append("func_id='" + Fc.lbIdFunc.Text + "',");
.
.
.
.
sqlBuilder.Append("FuncFuncao='" + Fc.cbFuncao.SelectedValue + "',");
sqlBuilder.Append("funcFoto='" + Fc.pbFuncFoto + "',"); //PICTUREBOX – This is the way I save the image
sqlBuilder.Append("sexo='" + Fc.cbSexo.Text + "',");
.
.
.
.
sqlBuilder.Append(" where func_id='" + Fc.lbIdFunc.Text + "'");
using (SqlConnection myconn = new SqlConnection(con.stringConexaoRH()))
try
{
myconn.Open();
using (SqlCommand cm = new SqlCommand(sqlBuilder.ToString(), myconn))
{
cm.ExecuteNonQuery();
MessageBox.Show ("Funcionário Adicionado com sucesso");
}
}
catch (Exception ex)
{
MessageBox.Show("" +ex);
}
}
private void btFoto_Click(object sender, EventArgs e)
{
try
{
// open file dialog
OpenFileDialog open = new OpenFileDialog();
// image filters
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp; *.png)|*.jpg; *.jpeg; *.gif; *.bmp; *.png";
if (open.ShowDialog() == DialogResult.OK)
{
// display image in picture box
pbFuncFoto.Image = new Bitmap(open.FileName);
// image file path
//textBox1.Text = open.FileName;
}
}
catch (Exception)
{
throw new ApplicationException("Houve falha na busca de Imagem....");
}
}
VulpesPosted Mar 18, 2014, 5:41 PM
If not, try commenting out this line which doesn't seem to be doing anything:
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(mstream);
Incidentally, what type of image is it?
Sousa PamboPosted Mar 18, 2014, 4:56 PM
the Error is "parameter is not valid". Well, I still don't get the point. please help
VulpesPosted Mar 18, 2014, 4:11 PM
To try and get some information on what's happening, change your catch clause as follows:
MessageBox.Show(ex.Message);
Sousa PamboPosted Mar 18, 2014, 3:15 PM
It gets the exception (ex) line, the default image. I think there is error at the lines before this one (ex) I really don't get what error is this. How could I do if it was a void not function? Please help.
VulpesPosted Mar 17, 2014, 11:44 AM
Sousa PamboPosted Mar 17, 2014, 1:57 AM
Actually It doesn't show any error (this the problem for me) it continues showing the default image I chose when a click my pbox. and I dont know how to bring error message for solving this problem.
Thank u all
VulpesPosted Mar 16, 2014, 5:08 PM