SQL Server Express LocalDB 可以远程连接吗?

发布于 2025-01-03 19:19:30 字数 767 浏览 1 评论 0原文

我正在考虑将新的 SQL Server Express LocalDB(我认为它的代号为“Denali”)用于桌面应用程序。

它当前使用 SQL Compact 运行,但用户希望在网络上的多台 PC 之间共享数据库。不幸的是,这不是 SQL Compact 可以做到的事情,因此我正在研究其他解决方案。

客户端需要能够轻松地将数据库文件发送到其他站点或将它们备份到闪存盘,因此我避免使用 SQL Express,因为备份和恢复需要相当多的“管理员”知识。

所以,我的问题是,新的 SQL Express LocalDB 是否支持通过网络和/或通过其中包含 mdf 文件的共享网络文件夹远程连接到数据库?

LocalDB 确实支持在其连接字符串(AttachDbFileName)中为附加的本地数据库提供路径,因此支持共享网络文件夹选项。

注意:此问题与 SQL Express 'Denali' 的新版本“LocalDB”有关,与 SQL Server Express 2008 或更低版本无关。 请参阅此处宣布 LocalDB 发布的文章:http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

原来分手还会想你 2025-01-10 19:19:30

不,SQL Server Express LocalDB 不接受远程连接。

共享网络文件夹的想法可能可行,但前提是您能够在尝试复制文件之前确保 LocalDB 实例已关闭。另请记住,只有一个 LocalDB 实例可以同时打开任何给定的数据库文件。并且不要忘记日志文件!

附加安全警告:与 SQL Server Compact 数据库不同,SQL Server Express 数据库(包括 LocalDB 数据库)并未设计为安全数据交换格式。例如,它们可能在嵌入其中的 .NET 程序集中包含恶意代码。因此,您永远不应该打开来自不受信任来源的数据库。

也许为客户提供一个自动执行备份过程的简单工具会是一个更好的主意?

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?

三生路 2025-01-10 19:19:30

这不是一个新鲜话题,但我想分享一下我使用 SQL Server Express 数据库 LocalDB 的经验。

我有一个 WPF C# 项目,使用 SQL 数据库和 LocalDb 引擎。它工作正常,没问题,我可以将数据库与 WPF 应用程序一起使用。我希望这个应用程序能够在具有更多 PC 的网络上运行。
在网络上,另一台 PC 可以使用连接字符串中的 UNC 路径来使用我的 PC 中的数据库。
在我看来,远程连接正在工作。但是,当连接远程 PC 时,我无法通过本地 WPF 应用程序使用数据库。如果我先运行我的应用程序,远程电脑将无法连接。所以这告诉我远程连接正在工作,但不允许多个连接。
好的,我没有放弃,我从我的 PC 运行该应用程序两次,我看到它正在工作,这告诉我同一个 SQL LocalDB 引擎只能在本地处理多个连接。

我希望这段经历能对某人有所帮助。谢谢。

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.

凯凯我们等你回来 2025-01-10 19:19:30

简而言之,是的,可以。这是教程关于如何配置它。

另外,这是另一篇文章< /a> 可能会出现潜在问题。

两者都解释了如何配置 SQL Server Express 以接受远程连接。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文