Not trusted connections?

Jonatan

Member
Joined
Jun 8, 2004
Messages
11
Location
Cuba
Programming Experience
3-5
Hello, I'm having big troubles when I setup an SqlConnection object to a remote SQL Server within an ASP.NET web application.

My Windows account is system administrator in the remote SQL Server. When I open the connection in the Server Explorer, it's all right. But look at this: when I create a ASP.NET web app and drop any table over the form designer, the SqlConnection object that was automatically generated by .NET seems to have troubles during login operation.

The error is given at runtime when I try to fill the dataset using the connection I talked about previously. The error page says:

Server Error in '/ProductsPerCategory' Application.

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

[font=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif]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 '(null)'. Reason: Not associated with a trusted SQL Server connection.

Source Error:

Line 77: 'Put user code to initialize the page hereLine 78: If Not Me.IsPostBack ThenLine 79: DACategories.Fill(DsCategories1)Line 80: DropDownList1.DataBind()Line 81: End If
Source File: C:\Inetpub\wwwroot\ProductsPerCategory\DataGridForm.aspx.vb Line: 79

Stack Trace:

[SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.] 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) ProductsPerCategory.DataGridForm.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\ProductsPerCategory\DataGridForm.aspx.vb:79 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()[/font]


Could someone help me please?
 
That's because ASP.NET runs under the ASPNET user, not as you. You need to either make it so your machines ASPNET user has permissions on the SQL server. Or to make it eaiser just use SQL Auth.
 
Error while adding ASPNET user to SQL Server

While trying to add the user ASPNET on my local machine 'AI-FUZZY' to the remote SQL Server I got the following error:

"Error 15401: Windows NT user or group AI-FUZZY\ASPNET not found. Check the name again"

Tell me something about it. I tried to add it both remotely from my PC and locally in the SQL Server PC, but no way it could be done.
 
I got it!

Further efforts are always rewarded. Finally I could access the SQL Server remote machine through an ASP.NET web app.

All I did is add the NT AUTHORITY\NETWORK SERVICE account to the logins of the SQL Server, and give it the proper access to Northwind database. Later, I established a connection from my web app using a SQL Server local account.

Perhaps this method is not the best, but it works... It pretty works! Praise the Lord!
:)
 
Back
Top