Solved

Cannot open database (IIS)

Posted on 2007-03-21
7
715 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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