Cant understand data source section of a given connection string

41 Views Asked by At

I have the following connection string and I am trying to make sense of it:

Data Source=(localdb)\.\DB;Initial Catalog=DB12;Integrated Security=True;Persist Security Info=False;Connect Timeout=60;Encrypt=False;Current Language=English;

The bit I am trying to understand Data Source=(localdb).\DB;Initial Catalog=DB12

(localdb) ==> Is this the instance of sql server or the machine name? .\ ==> Local machine name? DB ==> a folder in local instance of local sql server?

Initial Catalog=DB12 ==> The name of the database?

What difference would it make if I change above connection string to

(localdb)\.\DB   ===>  .\DB
1

There are 1 best solutions below

0
motosubatsu On

(localdb) refers to the "localdb" lightweight SQL Express installation that is installed with Visual Studio and with "SQL Server Express with Advanced Services", the \.\ means that the connection string is trying to connect to a shared instance of LocalDB - in this case one called "DB"

And the initial catalog does refer to the database it will initially be using when connected - so this connection string translates as

connect to the shared instance "DB" of LocalDB and the database called "DB12" in that instance.