From: shapper on
Hello,

I published a ASP.NET web site and copied the files to my computer
wwwroot to test it under IIS 7 in my computer before I send it to the
hosting server.

I get the following error (this web site uses a SQL 2008 Server
database):

Cannot open database "DBC" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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 "DBC" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

My Web.Config file is as follows:

<connectionStrings>
<add name="DBC.Domain.Properties.Settings.DBCConnectionString"
connectionString="Data Source=FLYONDREAMS\SQLEXPRESS;Initial
Catalog=DBC;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

I have only one user in my Windows, which is me, and which is
Administrator.

FlyOnDreams is the name I gave to WorkGroup when I installed windows
vista 64 bits.

On my SQL Server Express 2008 I have on Security:

Server Authentication: "SQL Server and Windows Authentication Mode"

Login Auditing: Failed Logins Only

Could someone tell me what might be wrong?

Thanks,

Miguel




From: Erland Sommarskog on
shapper (mdmoura(a)gmail.com) writes:
> Cannot open database "DBC" requested by the login. The login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> 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 "DBC" requested by the login. The login failed.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Is there a database DBC on the server?

Is the login NT AUTHORITY\NETWORK SERVICE user in database?

> I have only one user in my Windows, which is me, and which is
> Administrator.

But IIS tries log in with its service account.

> FlyOnDreams is the name I gave to WorkGroup when I installed windows
> vista 64 bits.

So IIS is not running in the same domain as the server? In that case,
I'm surprise that you got that far. I think an SQL login is better.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

From: shapper on
If I set integrated security to false and add the username and
password to the Connection String how can I define that user in the
SQL server so it can use that database?

From: Erland Sommarskog on
shapper (mdmoura(a)gmail.com) writes:
> If I set integrated security to false and add the username and
> password to the Connection String how can I define that user in the
> SQL server so it can use that database?

CREATE LOGIN someuser WITH PASSWORD='top$secret'
go
USE db
go
CREATE USER someuser



--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx