Click here to Skip to main content
15,125,228 members
Articles / Database Development / SQL Server / SQL Server 2008R2
Tip/Trick
Posted 21 Oct 2015

Stats

42.5K views
3 bookmarked

How to Resolve: "The Data Source value in the connection string specifies an instance of SQL Server that is not installed" or "LocalDB instance does not exist"

Rate me:
Please Sign up or sign in to vote.
4.50/5 (4 votes)
21 Oct 2015CPOL1 min read
The error occurs when we try to create a new Microsoft SQL Server Database File (SqlClient) using Visual Studio IDE

Introduction

This tip will give you the resolution to the error which occurs when one tries to create a SQL Server Database File using Visual Studio IDE.

Background

This error occurs if wrong configuration is provided in Visual Studio IDE for the Datasource. This happens when we are creating a SQL Server Database File using Visual Studio IDE.

Image 1

Error

Error if mdg file is already present:

Image 2

Error if mdf file is new:

Image 3

Resolution

Check in your Program Files the Folder for SQL Server, it must be located in "C:\Program Files\Microsoft SQL Server". This can be also found in the Environment Variables => Path.

Image 4

Search for "LocalDB" in that folder, if you find the folder, that means SQL Server Express is installed on your machine.

SQL Server Express is a free edition of SQL Server which comes along with Visual Studio IDE. This has limitations though but is very handy to create file databases and query on them. For more details on SQL Server Express Local Db.

Go to the bin folder of LocalDB for e.g., "C:\Program Files\Microsoft SQL Server\110\LocalDB\Binn".

Go to command prompt => type =>

C:\Program Files\Microsoft SQL Server\110\LocalDB\Binn\SqlLocalDB.exe i

Image 5

You will get the names of the installed LocalDB. In this case, only one localdb is installed, i.e., v11.0. These names will be prefix for creating connection string using local db, e.g., (LocalDB)\v11.0.....

To resolve the issue in Visual Studio IDE, go to In your Visual Studio IDE, go to Tools => Options => Database Tools => Database Connections. The below screenshot shows that wrong LocalDb is used as datasource, so change it to the right one, i.e., one which is installed.

Image 6

Corrected one:

Image 7

Click on Ok and you are done. Now try creating the mdf file using Visual Studio and it should work.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

yash soman
Technical Lead
India India
I have worked as a technical lead for MNC's. Currently, I conduct trainings on Microsoft Technologies at Ambrosia Knowledge Center. I am interested in learning new technologies,frameworks, designs etc. I like to distribute whatever knowledge i have so that more people can contribute and innovate things for our future. If you are facing any issues or problems and i could be help do feel free to connect me on my email link Send Mail.

My blog is Coding is Simple

Comments and Discussions

 
Generalsql Pin
Member 1435502417-May-19 0:19
MemberMember 1435502417-May-19 0:19 
QuestionCan't find SqlLocalDB.exe in file Pin
codetodead11-Apr-17 16:11
Membercodetodead11-Apr-17 16:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.