我是一名asp.net初学者,前几天买了本asp.net的书猛啃,但是到第七章被拦住了,有关数据库连接问题的.很简单,同样的问题在Windows 应用程序项目中不会出问题,但是到了asp.net 却不行,程序很简单,我是用Visual c#.net 2003做的.数据库是Sql2000.我把程序和运行的问题贴下,急了两天了,我甚至问了作者本人还是没解决.
行 28: private void Page_Load(object sender, System.EventArgs e)
行 29: {
行 30: this.sqlDataAdapter1.Fill(this.dataSet11,"sellTb1");
行 31: this.DataGrid1.DataSource=dataSet11.Tables["sellTb1"].DefaultView;
行 32: this.DataGrid1.DataBind();
运行后IE浏览器显示如下:
“/DataAccess”应用程序中的服务器错误。
--------------------------------------------------------------------------------
用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
源错误:
行 28: private void Page_Load(object sender, System.EventArgs e)
行 29: {
行 30: this.sqlDataAdapter1.Fill(this.dataSet11,"sellTb1");
行 31: this.DataGrid1.DataSource=dataSet11.Tables["sellTb1"].DefaultView;
行 32: this.DataGrid1.DataBind();// 在此处放置用户代码以初始化页面
源文件: d:\inetpub\wwwroot\dataaccess\webform1.aspx.cs 行: 30
堆栈跟踪:
[SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
DataAccess.WebForm1.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\dataaccess\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
行 28: private void Page_Load(object sender, System.EventArgs e)
行 29: {
行 30: this.sqlDataAdapter1.Fill(this.dataSet11,"sellTb1");
行 31: this.DataGrid1.DataSource=dataSet11.Tables["sellTb1"].DefaultView;
行 32: this.DataGrid1.DataBind();
运行后IE浏览器显示如下:
“/DataAccess”应用程序中的服务器错误。
--------------------------------------------------------------------------------
用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
源错误:
行 28: private void Page_Load(object sender, System.EventArgs e)
行 29: {
行 30: this.sqlDataAdapter1.Fill(this.dataSet11,"sellTb1");
行 31: this.DataGrid1.DataSource=dataSet11.Tables["sellTb1"].DefaultView;
行 32: this.DataGrid1.DataBind();// 在此处放置用户代码以初始化页面
源文件: d:\inetpub\wwwroot\dataaccess\webform1.aspx.cs 行: 30
堆栈跟踪:
[SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
DataAccess.WebForm1.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\dataaccess\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

浙公网安备 33010602011771号