We help IT Professionals succeed at work.

ASP.NET security configuration error:    Unable to connect to SQL Server database.

saturation asked
Medium Priority
Last Modified: 2012-05-06
I am getting the following error when trying to setup security config for my .NET site, but can't get past this error.  I have changed the connection string in my default website, given ASPNET user admin rights to the database, but still getting the error.  What else might be going wrong?

"There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database."
Watch Question

What does your connection string look like?  Are you using SQL Auth or Windows Auth?  Are you trying to connect to an existing database or are you using the ASPNET MDB file that connects to the SQL server as an instance?


            <add name="TestConnectionString" connectionString="Data Source=LAPTOP;Initial Catalog=Test;Integrated Security=True" providerName="System.Data.SqlClient"/>
Is the database installed as an instance? LAPTOP\SQLEXPRESS, or LAPTOP\SQL2005 ?

Are you running ASP.NET 2.0+?  You'll need to give access to Network Service in the database.


I'm not quite sure (not a pro at this), but the database was created through Enterprise Manager from SQL Server 2000.
When you connect to the database with enterprise manager, it should have the instance name there at the login screen..  It will either say LAPTOP or LAPTOP\SQL2000 or something like that.

If it's just LAPTOP, then that's what you'll connect to, but you may need to give Network Service access still.


It says "LAPTOP (Windows NT)" in Enterprise Manager....So...How do I give network service access?
In the enterprise manager, connect to the database, then go down to the Security section, under Users, add a new User.

You can probably hit the advanced button and search for the username, it may be something like LAPTOP\Network Service
Oh I forgot to mention, after you add the user, you'll want to set them as a dbowner on your database, or you could make them a global sysadmin if it's just for testing stuff on your laptop.
Here is the correct username NT AUTHORITY\Network Service


The only thing I see with "Network" in it is "Network Configuration Operators".  Is this it?
No, it should be NT AUTHORITY\Network Service

What OS are you running?


Win XP Pro...


Running it on my local machine...
Yeah on XP Pro you definitely should have that user, try typing it in manually to add the user.

NT AUTHORITY\Network Service


No such luck...I am running all of this locally.   Does that make a difference?
No, it shouldn't make a difference, you could just turn on SQL authentication and login with a SQL login on your connection string.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.