2
當我嘗試在C#中的Web應用程序中實現下載功能時,出現XML解析錯誤。相同的代碼在另一個Web表單中工作。XMLParsing錯誤
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();
你會得到什麼錯誤代碼?一個附註 - 你的代碼對SQL注入atack是開放的。 – Igor
運行此代碼時沒有警告,Web瀏覽器上的輸出是xml分析錯誤。 –
在〜/ Result'位置是否存在名稱存儲在變量'ab'中的文件? – Igor