Link to home
Start Free TrialLog in
Avatar of Regnillobian
RegnillobianFlag for United States of America

asked on

Connecting to SQL Server from ASP.NET web page

I have a SQL database that I access through ASP.NET to return XML. This is working fine on another server. I backed up that database on the other server and restored it to my local server, which should have identical setup. But when I run the ASP.NET page to retrieve data, I get the error message below. The login itself is not failing, which is Windows Authentication, because I can connect to the database using SQL Server Management Studio and run a query. IIS has impersonate set to true. Here is the error I receive from the ASP.NET web page.

Cannot open database "AAA" requested by the login. The login failed. Login failed for user 'BBB\cccc'. CommandText: CEConfig.Facility_List CommandType: 4 Parameter: @FacilityID Value: Parameter: @Name Value: Stack: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at SQLDatabaseConnector.DatabaseConnections.ExecuteReader(SqlCommand oCmd) Event Log Error: Cannot open log for source 'SQLDatabaseConnector'. You may not have write access.
Avatar of Regnillobian
Regnillobian
Flag of United States of America image

ASKER

I do have write access to directory C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL. I created a text file there and modified it.
SOLUTION
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
lol, that can do it :P
It was also helpful to check the SQL error log. That got us on the right track.
It was also helpful to check the SQL error log. That got us on the right track.