How to connect to LocalDb

后端 未结 10 1479
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 11:17

I installed LocalDb using the SqlLocalDb.msi package and I can connect to it using SSMS using the server name (LocalDb)\\v11.0. So far so good. The problem is t

相关标签:
10条回答
  • 2020-12-04 11:41

    I think you hit the same issue as discussed in this post. You forgot to escape your \ character.

    0 讨论(0)
  • 2020-12-04 11:41

    To locate a DB from SQL Server management studio can be done through browse - in the connect to database screen

    enter image description here

    Also make sure a local database is installed during installation:

    enter image description here

    0 讨论(0)
  • 2020-12-04 11:45

    You can connect with MSSMS to LocalDB. Type only in SERVER NAME: (localdb)\v11.0 and leave it by Windows Authentication and it connects to your LocalDB server and shows you the databases in it.

    0 讨论(0)
  • 2020-12-04 11:50

    I am totally unable to connect to localdb with any tool including MSSMA, sqlcmd, etc. You would think Microsoft would document this, but I find nothing on MSDN. I have v12 and tried (localdb)\v12.0 and that didn't work. Issuing the command sqllocaldb i MSSQLLocalDB shows that the local instance is running, but there is no way to connect to it.

    c:\> sqllocaldb i MSSQLLocalDB
    Name:               MSSQLLocalDB
    Version:            12.0.2000.8
    Shared name:
    Owner:              CWOLF-PC\cwolf
    Auto-create:        Yes
    State:              Running
    Last start time:    6/12/2014 8:34:11 AM
    Instance pipe name: np:\\.\pipe\LOCALDB#C86052DD\tsql\query
    c:\>
    c:\> sqlcmd -L
    
    Servers:
        ;UID:Login ID=?;PWD:Password=?;Trusted_Connection:Use Integrated Security=?;
    *APP:AppName=?;*WSID:WorkStation ID=?;
    

    I finally figured it out!! the connect string is (localdb)\MSSQLLocalDB, e.g.:

    $ sqlcmd -S \(localdb\)\\MSSQLLocalDB
    1> select 'hello!'
    2> go
    
    ------
    hello!
    
    (1 rows affected)    
    
    0 讨论(0)
  • 2020-12-04 11:53

    Your Connection string should be like`

    Data Source=(localdb)\ProjectsV13;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
    
    0 讨论(0)
  • 2020-12-04 11:53

    Suppose: SqlConnection connectionObj = new SqlConnection()

    for : connectionObj.ConnectionString -> use server name : (localdb)\\MSSQLLocalDB.

    Note: Double back slash

    for : App.config -> use server name : (localdb)\MSSQLLocalDB

    Note: Single back slash

    0 讨论(0)
提交回复
热议问题