本文介绍了使用asp.net更新图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



请检查以下代码并在此回复我更新图片有什么错误



源代码:



protected void btnUpdate_Click(object sender,EventArgs e)

{

string strimage = @ 〜\ProductImage \+ FileUpload1.FileName;

FileUpload1.PostedFile.SaveAs(Server.MapPath(strimage));

String strInsert =update UpdImage set名称= @姓名,照片= @照片,移动= @移动电子邮件= @电子邮件;

SqlCommand cmd = new SqlCommand(strInsert,con);



SqlParameter Name = new SqlParameter(@ Name,SqlDbType.VarChar);

Name.Value = txtName.Text.ToString();

cmd.Parameters.Add(Name);



SqlParameter Photo = new SqlParameter(@ Photo,SqlDbType.VarChar);

照片.Value = FileUpload1.FileBytes.ToString();

cmd.Parameters.Add(Pho to);



SqlParameter Mobile = new SqlParameter(@ Mobile,SqlDbType.VarChar);

Mobile.Value = txtmobile.Text .ToString();

cmd.Parameters.Add(Mobile);



SqlParameter EmailAddress = new SqlParameter(@ Email,SqlDbType .VarChar);

EmailAddress.Value = lblMail.Text.ToString();

cmd.Parameters.Add(EmailAddress);



尝试

{

con.Open();

cmd.ExecuteNonQuery();

upd();



}

catch(SqlException ex)

{



}

终于

{

con.Close();

}

}





这里照片路径的意思是:SqlParameter Photo = new SqlParameter(@照片,SqlDbType.VarChar);

Photo.Value = FileUpload1.FileBytes.ToString();

cmd.Parameters.Add(照片);



this是否正确和任何修改请回复我插入图像确定但更新未来请回复我

Dear All,

please check below code and reply me here what mistake update image

source code:

protected void btnUpdate_Click(object sender, EventArgs e)
{
string strimage = @"~\ProductImage\" + FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath(strimage));
String strInsert = "update UpdImage set Name=@Name, Photo=@Photo,Mobile=@Mobile where Email=@Email";
SqlCommand cmd = new SqlCommand(strInsert, con);

SqlParameter Name = new SqlParameter("@Name", SqlDbType.VarChar);
Name.Value = txtName.Text.ToString();
cmd.Parameters.Add(Name);

SqlParameter Photo = new SqlParameter("@Photo", SqlDbType.VarChar);
Photo.Value = FileUpload1.FileBytes.ToString();
cmd.Parameters.Add(Photo);

SqlParameter Mobile = new SqlParameter("@Mobile", SqlDbType.VarChar);
Mobile.Value = txtmobile.Text.ToString();
cmd.Parameters.Add(Mobile);

SqlParameter EmailAddress = new SqlParameter("@Email", SqlDbType.VarChar);
EmailAddress.Value = lblMail.Text.ToString();
cmd.Parameters.Add(EmailAddress);

try
{
con.Open();
cmd.ExecuteNonQuery();
upd();

}
catch (SqlException ex)
{

}
finally
{
con.Close();
}
}


here photo path means: SqlParameter Photo = new SqlParameter("@Photo", SqlDbType.VarChar);
Photo.Value = FileUpload1.FileBytes.ToString();
cmd.Parameters.Add(Photo);

this is correct or not and any modification please reply me inserting image ok but update not coming please reply me

推荐答案


这篇关于使用asp.net更新图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:19