使用asp.net更新Word文档? [英] Update Word document using asp.net?

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

问题描述

亲爱的所有人,

使用asp.net更新Word文档

下面的代码未更新Word文档,请检查并回复我

代码:

Dear All,

update word document using asp.net

below code not updating word document please check and reply me

code:

protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string connectionString = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        string strUpdate = "UPDATE submittable1 SET Detaileddata=@Detaileddata where emailAddress=@emailAddress";
        //Create SQL connection
        SqlConnection con = new SqlConnection(connectionString);
        //Create SQL Command And Sql Parameters
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = strUpdate;

string DetailedData = @"~\ProductImages\" + FileUpload1.FileName;
        FileUpload1.PostedFile.SaveAs(Server.MapPath(DetailedData));

        SqlParameter Detailed1 = new SqlParameter("@DetailedData", SqlDbType.VarBinary);
        Detailed1.Value = DetailedData.ToString();
        cmd.Parameters.Add(Detailed1);

        SqlParameter Detaileddata = new SqlParameter("@Detaileddata", SqlDbType.VarBinary);
        Detaileddata.Value = FileUpload1.FileName.ToString();
        cmd.Parameters.Add(Detaileddata);

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

        try
        {
            con.Open();
            //int result = cmd.ExecuteNonQuery();
            cmd.ExecuteNonQuery();
            Response.Redirect("Update.aspx");
        }
        catch (SqlException ex)
        {

        }
        finally
        {
            con.Close();
        }
        
    }

推荐答案

您的sql语句不正确,没有提供参数,请确保您提供了正确的表名和列名,并使用大写或小写字母.

your sql statement is incorrect, not given parameters and make sure you have gave the correct table names and columns names with upper or lower case letters.

string strUpdate = "UPDATE submittable1 SET Detaileddata = @Detaileddata where emailAddress=@EmailAddress";


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆