User Instance of SqlLocalDb

Siddharood picture Siddharood · Dec 27, 2012 · Viewed 16.8k times · Source

I am getting this Exception When I am trying to access database from C#.

My Connection String is

Data Source=(localdb)\v11.0;integrated security=true;User Instance = true;AttachDbFileName=C:\Users\UserName\Desktop\DB\TestDB3.mdf

Exception is

The user instance login flag is not allowed when connecting to a user instance of SQL Server. The connection will be closed.

Answer

Krzysztof Kozielczyk picture Krzysztof Kozielczyk · Dec 27, 2012

LocalDB instances are all "User Instances", and there's no need to specify User Instance=true in your connection string, in fact it is not even supported (as you can see). Just remove this part and it's going to work fine.