Can SQL Server Express LocalDB be connected to remotely?

[亡魂溺海] 提交于 2019-11-26 11:29:00

问题


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


回答1:


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?




回答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.




回答3:


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 access the database. I wanted this program to work on network with more PCs. In my scenario 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. But when the remote PC is connected, I could not connect to my database. If I connected 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 program from my PC twice and I saw it is working which tells me that the same SQL LocalDB engine can connect several times.

I hope this experience will help someone. Thanks.



来源:https://stackoverflow.com/questions/9193746/can-sql-server-express-localdb-be-connected-to-remotely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!