October 28, 2004

SQLServer2000 & C# - Error

If you have these problems after the connecting to SQLServer check these
  • Check your Service Manager for runnig.
  • Do you used of Data Source=NET101 in ConnectionString? (NET101 is my computer name)
  • Do you used of SERVER=localhost in ConnectionString?
  • Test IP for connection 127.0.0.1
  • Run Enterprise Manager > (local)(WindowsNT) > (RightClick)Properties > Security > (select) SQL Server and Windows
  • Add ASPNET user that is predefine user to users at Enterprise Manager and set full accessibility to tables and Stored Procedures


Login failed for user NT AUTHORITY\NETWORK SERVICE
Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Source Error:
Line 28: private void Page_Load(object sender, System.EventArgs e)
Line 29: {
Line 30: sqlDataAdapter1.Fill(dataSet11, "_UNPass");
Line 31: DataGrid1.DataBind();
Line 32: }
Source File: c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs Line: 30
Stack Trace:
[SqlException: Login failed for user '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
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)
WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573


Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------
General network error. Check your network documentation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: General network error. Check your network documentation.
Source Error:
Line 29: {
Line 30: //sqlConnection1.Open();
Line 31: sqlDataAdapter1.Fill(dataSet11, "_UNPass");
Line 32: DataGrid1.DataBind();
Line 33: //sqlConnection1.Close();
Source File: c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs Line: 31
Stack Trace:
[SqlException: General network error. Check your network documentation.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +474
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs:31
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573


- احتمالا Service Manager رو بالا نیاوردید.
- ConnectionString تون مشکل داره. مثلا برای کامپیوتری با نام NET101 این رو بد نیست بذارید. Data Source=NET101
- فکر کنم با افزودن SERVER=localhost به فیلد ConnectionString کامپوننت SqlConnection حله (البته برای کاربرهای خونگی)
- به جای نام کامپیوتر (اگه تو شبکه هم هست) بهتره که از IP استفاده کنید مثل 127.0.0.1
- گرچه برای من این جوری دستکاری تو Enterprise Manager حل شد :
Run Enterprise Manager>(local)(WindowsNT)>(RightClick)Properties>Security>(select) SQL Server and Windows
- افزودن USER ی به نام ASPNET اگه تو لیست user های Enterprise Manager هست بد نیست گرچه من userی به نام IIS... رو هم اضافه کردم ولی همون اولی کافیه که اضافه کنید و به لیست user های table دیتابیستون اضافش کنید و بهش هر دسترسی که می خواد بدین تا کارتون بگذره ;-)

1 comment:

Android app developers said...

This is one of the knowledgeable post.This is one of the valuable information.Thanks for your support.