1
votes

When I try to create an Sql Server Database in the App_Data folder of my Visual Studio 2010 project, I get the following error:

Login failed for user:[Domain]\[user]

I am able to create databases using Sql Server Management Studio. I am using Sql Server Express 2008.

Any help regarding this is appreciated. Thanks in advance!

2

2 Answers

0
votes

As you are using express edition, in Visual Studio go to Tools>Options>Database Tools>Data Connections.

Remove the SQL Server Instance Name and click OK.

Now try connection to the server using Server Explorer. Once you get connected, you will be able to create a new DB in App_Data folder.

Here is the connection string:

public string ConStr = "Data Source=.;AttachDbFilename=|DataDirectory|CodeDB.mdf;
Integrated Security=True;User Instance=True";

Also make sure that you have user instances for your DB enabled.

0
votes

In Visual Studio 2013:

Go to Tools-->> Options-->>Database Tools-->>Data Connections. SQL Server Instance Name

Type ProjectsV12

Then Create SQL Server Database inside the App_Folder, and it will work.

Open CommandPrompt as administrator

Type sqllocaldb info and press enter

It will display all the available local db.