Solved

Cannot open database (IIS)

Posted on 2007-03-21
7
721 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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