8
Answers

retrieve image from database

Ankita Singh

Ankita Singh

6y
657
1
protected void btnUpdate_Click(object sender, EventArgs e)
{
string id = Request.QueryString["id"].ToString();
string qry = "update appformtbl set can_name=@can_name,fath_name=@fath_name,photo=@photo,sign=@sign,pass_gra=@pass_gra where id=" + id + "";
SqlConnection con = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand(qry, con);
if (image1.HasFile)
{
image1.SaveAs(MapPath("~/Rimage/" + image1.FileName));
System.Drawing.Image img1 = System.Drawing.Image.FromFile(MapPath("~/Rimage/") + image1.FileName);
NormalImage.ImageUrl = "~/Rimage/" + image1.FileName;
}
else
{
var preimg = cmd.Parameters.AddWithValue("@photo", image1.ToString());
if (image1!= null)
{
preimg.Value = image1.FileName;-
}
}
 
cmd.Parameters.AddWithValue("@photo", SqlDbType.NVarChar).Value = image1.FileName.Trim();
 
my problem:- hello friends, when i am updating new image then show in table but without change image click on update button then not find previous image...  how to do it??? please help me.. thank you
Answers (8)