2

尝试在 C# 中的 Web 应用程序中实现下载功能时出现 XML 解析错误。相同的代码在另一个 Web 表单中运行。

SqlConnection cn = new SqlConnection();

cn.ConnectionString =ConfigurationManager.ConnectionStrings["cn"].ConnectionString.ToString();
cn.Open();

String abc = null;

SqlCommand cm = new SqlCommand("select User_ID from Mgmt where S_Name='" + DropDownList1.Text + "'", cn);

SqlDataReader dr = cm.ExecuteReader();

if (dr.Read())
{
    abc = dr.GetString(0).ToString();
}

dr.Close();
cm.Dispose();

String ab = null;

SqlCommand cmd = new SqlCommand("select Result from Result where Clg_ID='" + abc + "'and Student_ID='" + TextBox1.Text + "'", cn);
SqlDataAdapter drr = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

drr.Fill(ds);

ab = ds.Tables[0].Rows[0][0].ToString();

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename='"+ab+"'");
Response.TransmitFile(Server.MapPath("~/Result/"+ab));
Response.End();

cn.Close();
4

1 回答 1

0

经过大量的努力,我得到了自己问题的可能答案。这不是一个准确的答案。我刚换了电脑,然后这个错误就没有了,回到我以前的电脑,错误也得到了解决。我仍然不知道是什么导致了错误以及它是如何解决的。

于 2012-12-31T06:03:34.257 回答