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.
RegnillobianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RegnillobianAuthor Commented:
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.
0
Randy PooleCommented:
In SQL Management Studio open up the database and select the security node.
Remove the user "BBB\cccc" from there if it exists, add a new user and select the same user and give them the permissions.  It looks like although the account is there it is pointing to an ID on the other SQL Server which is not the same on this one.
0
RegnillobianAuthor Commented:
I tried that and it did not change anything. After spending a couple more hours on this, we found out the database was restored to a slightly different name, which is why our connection was not working. So SQL was telling us login failed, but should have said DB did not exist. Thanks for your assistance.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Randy PooleCommented:
lol, that can do it :P
0
RegnillobianAuthor Commented:
It was also helpful to check the SQL error log. That got us on the right track.
0
RegnillobianAuthor Commented:
It was also helpful to check the SQL error log. That got us on the right track.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.