Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot open database (IIS)

Posted on 2007-03-21
7
Medium Priority
?
724 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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