Can SQL Server Express LocalDB be connected to remotely?
Asked Answered
K

3

34

I am looking into using the new SQL Server Express LocalDB (I think it is code named "Denali") for a desktop application.

It is currently running with SQL Compact, but the user is wanting to share the database between multiple PCs on a network. Unfortunately this is not something that SQL Compact can do, so I am investigating other solutions.

The client requires the ability to send database files easily to other sites or to back them up to a flash disk, so I am avoiding going to SQL Express because there is quite a bit of "administrator" knowledge required to backup and restore.

So, my questions is, does the new SQL Express LocalDB support remote connections to the database over a network and/or through a shared network folder with the mdf file in it?

LocalDB does support supplying a path for an attached local DB in it's connect string (AttachDbFileName) hence the shared network folder option.

NOTE: This question pertains to "LocalDB" the new version of SQL Express 'Denali' and not to SQL Server Express 2008 or prior. See article here announcing LocalDB's release: http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx

Kentledge answered 8/2, 2012 at 12:57 Comment(2)
Clarification on the "Denali" part: Denali was the code name for SQL Server 2012, not for the LocalDB version of SQL Server Express. I think the confusion comes from the fact that LocalDB was introduced in CTP3 of SQL Server 2012, when it was still called SQL Server "Denali".Berry
Thanks Krzysztof! Now I understand :)Kentledge
B
31

No, SQL Server Express LocalDB doesn't accept remote connections.

The idea with shared network folder might work, but only if you are able to make sure the LocalDB instance is shutdown before you try to copy the file. Also keep in mind that only one LocalDB instance can have any given database file open at the same time. and don't forget about the log files!

Additional security warning: unlike SQL Server Compact databases, SQL Server Express databases (including LocalDB ones) are not designed as secure data exchange format. For instance, they can contain malicious code in .NET assemblies embedded in them. So you should never open databases from untrusted source.

Maybe providing the customer with a simple tool that automates the backup process would be a better idea?

Berry answered 9/2, 2012 at 19:12 Comment(1)
Thanks! A very comprehensive answer. The automated backup option unfortunately won't work because the client wants to be able to share and email the database as you would a word doc or the like. Any file based DBs that you would recommend for this that would support remote connections?Kentledge
L
4

This isn't a fresh thread, but I would like to share my experience with SQL Server Express database LocalDB.

I have a WPF C# project using SQL database with LocalDb Engine. It is working fine no problem, I can use the database with the WPF app. I wanted this app to work on network with more PCs. On the network another PC can use the database from my PC using UNC path in the connection string.
It seemed to me the remote connection is working. However when the remote PC is connected, I am not able to use the database with my local WPF app. If I run my app first the remote PC could not connect. So this tells me that the remote connection is working, but the multiple connection is not allowed.
OK, I didn't give up and I run the app from my PC twice and I saw it is working which tells me that the same SQL LocalDB engine can handle multiple connections locally only.

I hope this experience will help someone. Thanks.

Lishalishe answered 11/8, 2017 at 12:18 Comment(3)
This blob of text is super-hard to comprehend. It is not useful if it stays like this. Simple sentences. Subject verb object. And use paragraphs to separate contentDryfoos
Sorry guys, I really tried to format this text, but I couldn't put new line in the text. How can I do new paragraph?Lishalishe
@Zoltan, thanx for chiming in w/ your experience. I gather what you said above is: a) a localdb database can be accessed via unc path b) localdb supports concurrent connections to the same database from applications on the same computer that hosts the database c) localdb does not support concurrent connections to a database from applications on different computers I find (c) surprising since this is something "even msaccess" supports. And it doesn't say whether one can have multiple connections from 1 remote computer. Anyway, moot point, and I'll look at sql-server-coreCharlot
W
2

In short, yes it can. Here is a tutorial on how to configure it.

Also, here is another post with a potential issue that might occur.

Both explain how to configure SQL Server Express to accept Remote Connections.

Wrinkly answered 8/2, 2012 at 12:59 Comment(2)
Thanks for your input, but my question is referring to "LocalDB" the new version of SQL Express 'Denali'. I will update the question to be more clear in this regard. Thanks!Kentledge
The first link is no longer available. Maybe this link, which comes from the other domain, will be applicable: linglom.com/it-support/…Unblinking

© 2022 - 2024 — McMap. All rights reserved.