views:

48

answers:

5

I am not used to work with SQL Server(usually I just use express). I run it on windows server 2008, iis7.

I have attached the database to my sql server. I made a web site in iis7 but I get this error message.

Cannot open database "Phaeton.mdf" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Connectionstring I use

<add key="PhaetonConnectionString" value="Data Source=.;Initial Catalog=Phaeton.mdf;Integrated Security=True"/> 

Thanks

+1  A: 

Since you are using Integrated Security the SQL connection will use the windows identity which is passed from ASP.NET.

You can either change your security to mixed-mode which will involve removing the integrated security. Or use impersonation (check IIS and your web.config) and grant that user access to the database.

Hope that helps

Nina
+1  A: 

You need to configure your application in IIS to turn off anonymous access and turn on Windows authentication(If yoy want to use integrated security).

Access SQL Server Using Windows Integrated Security

The other way, you can use a connection string with user/password ... with the appropriate login

Svetlozar Angelov
I don't want to use the windows authentication. I rather use a user/password type. Where do I setup that? I am going to have about 5 sites on my server now so is there a way to do seperate user for each site?
Dejan.S
Well, you can create an SQL Login (From Sql Management Studio for example) and you can assign rights to which database and databases objects it has access.
Svetlozar Angelov
A: 

For setting up users take a look at How To: Use Membership in ASP.NET 2.0

kevchadders
A: 

Problem was that the database I tried to attach was sql express

Dejan.S
You can attach a SQL Express database to a newer version of SQL Server. You just can't reattach it to the old SQL Express server again afterward.
Aaronaught
A: 

The problem is here:

Initial Catalog=Phaeton.mdf

In SQL Server Express, you can attach a filename as a local database. That's not how it works on a production SQL Server. In non-Express versions you attach a database permanently, which it looks like you've already done, and you give it a logical name, which is not the same as the primary file name.

I would guess that if the file name was "Phaeton.mdf" then you probably named the database "Phaeton". In which case that part of the connection string should simply be:

Initial Catalog=Phaeton

If that's not the right name, you can get a list of database names from the server using the following script:

USE master;
SELECT name FROM sys.databases
Aaronaught