用ASP.NET联接SQL Server相关的问题(在线等)
下面是我的代码:
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>
<html>
<head>
<title>Beginning ASP.NET Databases Using C#:Chapter 3</title>
</head>
<body>
<h4>First Example:Listing data from the Employees table</h4>
<asp:DataGrid id="dgNameList"
runat=server
GridLines="None"
BackColor="LightBlue"
CellPadding="5"
CellSpacing="5"
BorderWidth="2"
BorderColor="Black"
ToolTip="Includes only those employees who are at HQ" />
</body>
</html>
<script language=C# runat=server>
private void Page_Load(object sender,System.EventArgs e)
{
String strConnection = "server=HARVARD\\MYSQL;database=Northwind; integrated security=true;";
SqlConnection objConnection=new SqlConnection(strConnection);
String strSQL = "SELECT FirstName,LastName,Country"+"FROM Employees";
SqlCommand objCommand=new SqlCommand(strSQL,objConnection);
objConnection.Open();
dgNameList.DataSource = objCommand.ExecuteReader();
dgNameList.DataBind();
objConnection.Close();
}
</script>
---------------------------------------------
以下是错误信息:
“/WebApplication2”应用程序中的服务器错误。
--------------------------------------------------------------------------------
用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
源错误:
行 30: SqlCommand objCommand=new SqlCommand(strSQL,objConnection);
行 31:
行 32: objConnection.Open();
行 33: dgNameList.DataSource = objCommand.ExecuteReader();
行 34: dgNameList.DataBind();
源文件: d:\inetpub\wwwroot\WebApplication2\SQLServer-connection.aspx 行: 32
堆栈跟踪:
[SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
ASP.SQLServer_connection_aspx.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\WebApplication2\SQLServer-connection.aspx:32
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
请问各位高手,是哪儿出了问题:)在线等,急!~~~~~~~~~~~~~~~~