Solved

Cannot open database (IIS)

Posted on 2007-03-21
7
722 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 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