Using LocalDB on a network

Toby 1 Reputation point
2022-03-11T05:39:20.313+00:00

I'm trying to share a SQL LocalDB database on our network to allow two computers to view, add and update records to the same database.
I've shared the folder containing the database on our network and so far i have been able to access the database using both computers but only one computer can access it at the time.

Is it possible to have two computers access the database at the same time?

I am using VB.Net. The connection string i use now is Server=(LocalDb)\MSSQLLocalDB;Trusted_Connection=True;AttachDbFileName=C:\MyTables\table1.mdf

If i can share the database on our network, what needs to change to the above string for this to occur?

Thanks

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,645 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,450 questions
SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
490 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,436 Reputation points
    2022-03-11T07:20:49.287+00:00

    Hi @Toby ,

    Welcome to Microsoft Q&A!
    Your database seems to be set to single-user mode. In Management Studio, open database properties window. In Options page, check State. It should be set to MULTI_USER, not SINGLE_USER.
    182158-1.png

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Olaf Helper 40,656 Reputation points
    2022-03-11T08:17:22.657+00:00

    to share a SQL LocalDB database on our network to

    It's called Local DB because it works on local, not over Network.
    Use SQL Server Express Edition instead.

    0 comments No comments

  3. Erland Sommarskog 100.8K Reputation points MVP
    2022-03-11T22:29:24.617+00:00

    As Olaf says, this is not going to work out, if for slightly different reasons.

    Yes, you can put the local DB on a network share, so that a user on a different machine can access the database. But localdb runs in the user address space, so if you then try to access the database by running LocalDB on your instance, the database is locked by the other instance.

    And, no, you cannot access a localdb instance running on a different machine. Again, localdb runs in user space.

    So Olaf is right: you need to run the full SQL Server Express edition, and configure it to accept remote connections.

    0 comments No comments