该引入什么命名空间

hemudu 2003-10-09 08:33:23
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0246: 找不到类型或命名空间名称“XmlDocument”(是否缺少 using 指令或程序集引用?)

源错误:



行 7: {
行 8: String FilePath = Server.MapPath("menu.xml");
行 9: XmlDocument doc = new XmlDocument();
行 10: doc.Load(FilePath);
行 11: XmlNodeList nodes = doc.SelectNodes("基础数据");


源文件: F:\www\www.ezhen.com\read.aspx 行: 9


显示完整的编译源:


行 1: //------------------------------------------------------------------------------
行 2: // <autogenerated>
行 3: // This code was generated by a tool.
行 4: // Runtime Version: 1.0.3705.288
行 5: //
行 6: // Changes to this file may cause incorrect behavior and will be lost if
行 7: // the code is regenerated.
行 8: // </autogenerated>
行 9: //------------------------------------------------------------------------------
行 10:
行 11: namespace ASP {
行 12: using System;
行 13: using System.Collections;
行 14: using System.Collections.Specialized;
行 15: using System.Configuration;
行 16: using System.Text;
行 17: using System.Text.RegularExpressions;
行 18: using System.Web;
行 19: using System.Web.Caching;
行 20: using System.Web.SessionState;
行 21: using System.Web.Security;
行 22: using System.Web.UI;
行 23: using System.Web.UI.WebControls;
行 24: using System.Web.UI.HtmlControls;
行 25:
行 26:
行 27: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
行 28: public class read_aspx : System.Web.UI.Page, System.Web.SessionState.IRequiresSessionState {
行 29:
行 30: private static int __autoHandlers;
行 31:
行 32: private static bool __intialized = false;
行 33:
行 34: private static System.Collections.ArrayList __fileDependencies;
行 35:
行 36:
行 37: #line 5 "F:\www\www.ezhen.com\read.aspx"
行 38:
行 39: public void Page_Load(Object o, EventArgs e)
行 40: {
行 41: String FilePath = Server.MapPath("menu.xml");
行 42: XmlDocument doc = new XmlDocument();
行 43: doc.Load(FilePath);
行 44: XmlNodeList nodes = doc.SelectNodes("基础数据");
行 45: int Count = nodes.Count;
....................................


--------------------------------------------------------------------------------
版本信息: Microsoft .NET 框架版本:1.0.3705.288; ASP.NET 版本:1.0.3705.288
...全文
80 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hemudu 2003-10-10
  • 打赏
  • 举报
回复
谢谢superch0054(竹君子)

我范了这样低级的错误
竹君子 2003-10-10
  • 打赏
  • 举报
回复
给你 看一个手写的读取数据库的例子把

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script Language="c#" runat="server">
void Page_Load()
{
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=C:\BegASPNET\ch12\Northwind.mdb";
data_src.Text = strConnection;
string strSQL = "SELECT FirstName,LastName FROM Employees";
string strResultsHolder = "";
OleDbConnection objConnection = new OleDbConnection(strConnection);
OleDbCommand objCommand = new OleDbCommand(strSQL, objConnection);
OleDbDataReader objDataReader = null;
try
{
objConnection.Open();
con_open.Text="Connection opened successfully.<br>";
objDataReader = objCommand.ExecuteReader();
while (objDataReader.Read() == true)
{
strResultsHolder += objDataReader["FirstName"];
strResultsHolder += " ";
strResultsHolder += objDataReader["LastName"];
strResultsHolder += "<br/>";
}
objDataReader.Close();
objConnection.Close();
con_close.Text = "<br/>Connection closed.<br/>";
divListEmployees.InnerHtml = strResultsHolder;
}
catch (Exception e)
{
con_open.Text = "Connection failed to open successfully.<br/>";
con_close.Text = e.ToString();
}
}
</script>
<html>
<body>
<h4>Reading data from the connection
<asp:label id=data_src runat=server/> with the DataReader object.</h4>
<asp:label id=con_open runat=server/><br>
<div id="divListEmployees" runat="server">list will go here</div>
<asp:label id=con_close runat=server/><br>
</body>
</html>
竹君子 2003-10-10
  • 打赏
  • 举报
回复
我 知道 了,虽然你 引用了,但没引用对阿
把using System.Xml;
改成<%@ Import Namespace="System.Xml" %>就可以了
你是在aspx页面上直接写的,不是在后台写的,所 不是用using来引用命名空间
hemudu 2003-10-10
  • 打赏
  • 举报
回复
请兄弟帮帮i吧
hemudu 2003-10-09
  • 打赏
  • 举报
回复
using System.Xml;
我不是已经在源代码里面写了,这是为什么?还是不对
树猫 2003-10-09
  • 打赏
  • 举报
回复
using System.Xml;
hemudu 2003-10-09
  • 打赏
  • 举报
回复
部分源代码
<%@Page Language="C#" %>

using System.Xml;

<script language="C#" runat=server>
public void Page_Load(Object o, EventArgs e)
{
String FilePath = Server.MapPath("menu.xml");
XmlDocument doc = new XmlDocument();
doc.LoadXML(FilePath);
XmlNodeList nodes = doc.SelectNodes("基础数据");
int Count = nodes.Count;

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧