我在我的asp.net页面得到这个消息。在asp.net页面编译错误
任何建议,以解决此问题将不胜感激。谢谢。
编译错误 说明:编译服务此请求所需的资源时发生错误。请查看以下具体的错误细节并适当修改您的源代码。编程器错误消息:ASPNET:确保此代码文件中定义的类匹配'inherits'属性,并且它扩展了正确的基类(例如Page或UserControl)。
源错误:
Line 1: using System;
Line 2: using System.Data;
Line 3: using System.Data.SqlClient;
的ASPX代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
的C#代码:
using System;
using System.Data;
using System.Data.SqlClient;
class SqlConnectionDemo
{
static void Main()
{
SqlConnection conn = SqlConnection("Data Source=(local); Initial Catalog=JobSearchManager;Integrated Security = SSPI");
SqlDataReader rdr = null;
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("select * from Agency", conn);
rdr = cmd.ExecuteReader;
while (rdr.Read())
{
Console.WriteLine(rdr[0]);
}
}
finally
{
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close;
}
}
}
}
试着大声阅读“编译器错误消息”。然后看看你的类声明。 – 2010-01-17 22:02:41
我不明白........ – LearningCSharp 2010-01-17 22:05:53
你可以添加代码隐藏文件_Default.aspx.cs的代码吗? – 2010-01-17 22:33:02