Products.aspx出错,该如何改(100分)请调试过再做答。
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<script Runat="Server" Language="C#">
void Page_Load(Object sender,EventArgs e) {
SqlConnection conNorthwind;
SqlCommand cmdProducts;
DataSet dstProducts;
string strQuery;
conNorthwind=new SqlConnection("Server=localhos;UID=sa;PWD=weiYI10!;Database=Northwind");
strQuery="select ProductName As Text from Products As TreeNode where CategoryID=@categoryID for xml
auto,XMLDATA";
cmdProducts=new SqlCommand(strQuery,conNorthwind);
cmdProducts.Parameters.Add(new SqlParameter("@categoryID", Request.QueryString("catID")));
conNorthwind.Open();
dstProducts=new DataSet();
dstProducts.ReadXml(cmdProducts.ExecuteXmlReader(),XmlReadMode.Fragment);
dstProducts.DataSetName="TREENODES";
dstProducts.WriteXml(Response.OutputStream);
conNorthwind.Close();
}
</script>
出错提示:
“/s”应用程序中的服务器错误。
--------------------------------------------------------------------------------
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0118: “System.Web.HttpRequest.QueryString”表示“属性”,此处应为“方法”
源错误:
行 12: strQuery="select ProductName As Text from Products As TreeNode where CategoryID=@categoryID for xml auto,XMLDATA";
行 13: cmdProducts=new SqlCommand(strQuery,conNorthwind);
行 14: cmdProducts.Parameters.Add(new SqlParameter("@categoryID", Request.QueryString("catID")));
行 15: conNorthwind.Open();
行 16: dstProducts=new DataSet();
源文件: C:\Inetpub\wwwroot\s\Products.aspx 行: 14