Solved

Cannot open database (IIS)

Posted on 2007-03-21
7
714 Views
Last Modified: 2007-12-19
Hi
I have a asp.net website which runs fine when I click play in visual studio.
I have just added it to IIS in order to access it from another machine on the network.

However I get this error when I go to
http://localhost/e-services/

Any ideas?

Thanks
H

Server Error in '/E-Services' Application.
--------------------------------------------------------------------------------

Cannot open database "E-Services" requested by the login. The login failed.
Login failed for user 'mymachine\ASPNET'.
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: Cannot open database "E-Services" requested by the login. The login failed.
Login failed for user 'mymachine\ASPNET'.

Source Error:


Line 18:         //define and open sql connection
Line 19:         sqlconn = new SqlConnection("server = localhost; database = E-Services; integrated security=true");
Line 20:         sqlconn.Open();

 
0
Comment
Question by:hmcgeehan
  • 3
  • 2
7 Comments
 

Author Comment

by:hmcgeehan
ID: 18762968
BTW I went to SQL SERVER and into my database and ran the command

exec sp_grantlogin 'mymachine\ASPNET'

but still the same error

0
 
LVL 7

Expert Comment

by:here4u247
ID: 18762980
you might need to add login details to your SQL DB, i.e.

sqlconn = new SqlConnection("server = localhost; database = E-Services; uid=sa;pwd=password; integrated security=true");





0
 

Author Comment

by:hmcgeehan
ID: 18762999
In SQL SERVER I added
'mymachine\ASPNET'
under
Security
Users

Now the error is

Server Error in '/E-Services' Application.
--------------------------------------------------------------------------------

SELECT permission denied on object 'categories', database 'E-Services', schema 'dbo'.
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: SELECT permission denied on object 'categories', database 'E-Services', schema 'dbo'.

Source Error:


Line 158:        SqlDataAdapter dadEServices = new SqlDataAdapter("SELECT * FROM eservices ORDER BY title ASC", sqlconn);
Line 159:        DataSet ds = new DataSet();
Line 160:        dadCategories.Fill(ds, "categories");
Line 161:        dadSectors.Fill(ds, "sectors");
Line 162:        dadEServices.Fill(ds, "eservices");
 
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:hmcgeehan
ID: 18763215
ok on my machine its problem solved
i went into
control panel
users and passwords
and modified
'mymachine\ASPNET'
to be an adminsitrator

BUT
when someone else on the network tries to browse to the page it asks for a username and password
0
 
LVL 7

Accepted Solution

by:
here4u247 earned 50 total points
ID: 18763971

Solution #1:

if you know the password of sa (sql login) then i recommend to use that, if not go:
Server Enterprise Manager --> Security Tab --> Right Click on sa (Server Administrator)---> select properties --> type a new password


sqlconn = new SqlConnection("server = localhost; database = E-Services; uid=sa;pwd=newPassword; integrated security=true");



Solution #2:


Server Enterprise Manager --> Database --> E-Services --> Users --> Right Click --> new Database user --> Select Login Dropdownlist --> select <new> --> type name --> Select SQL server authentication --> type password --> on database select E-Services --> press OK --> you will return to the initial screen --> select all appropriate database membership role


use the new details in your connectionstring:

sqlconn = new SqlConnection("server = localhost; database = E-Services; uid=newDBuser;pwd=newPassword; integrated security=true");

Hope that helps


0
 
LVL 22

Expert Comment

by:cj_1969
ID: 19911853
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
 
I will leave the following recommendation for this question in the Cleanup Zone:
Accept - here4u247 {18763971}
 
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
 
cj_1969 - Experts Exchange Cleanup Volunteer
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now