从使用 SQL Server Express 切换到 SQL Server Compact
到目前为止,我一直在桌面应用程序上使用 SQL Server Express,尽管服务器通常仅由同一台计算机上的单个应用程序、单个用户使用。这对我来说总是有点愚蠢,因为完整的服务器相当重。
然后我发现有一个叫做SQL Server Compact的东西。问题是,我的应用程序已经相当大了。所以我的问题是,如果我想更改为 SQL Server Compact,我们正在讨论对我的代码进行什么样的更改(使用 C#)?
主要是我想知道是否可以像访问 Express 版本一样访问 Compact 版本,即使用 ADO.NET 并将其指向 localhost\sqlexpress。那么是否可以使用 Compact 创建另一个实例,然后将我的应用程序指向该实例,或者以完全不同的方式使用它?
So far I have been using SQL Server Express on my desktop application even though usually the server is only used by that single application, by the single user, on the same single machine. This always seemed a bit silly to me since the full-on server is rather heavy.
Then I found out that there is something called SQL Server Compact. Thing is, my application is already rather large. So my question is that if I wanted to change to SQL Server Compact, what kind of changes to my code are we talking about (using C#)?
Mainly I'm wondering if I can access the Compact -version in the same manner as I can access the Express one, which is using ADO.NET and pointing it towards localhost\sqlexpress. So would it be possible to create another instance with the Compact and just point my application to that, or is it used in a completely different manner?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于独立的桌面产品来说,与 SQL Express 相比,它无疑是一个值得考虑的轻量级选项。
然而,除了连接字符串之外,两者之间还有一些差异需要注意。例如,SQL CE 不支持存储过程、用户定义函数或触发器。此外,它不支持 Express 支持的全部数据类型。在技术层面上,它也与您的应用程序一起运行。
另一个考虑因素是,虽然 SSMS 将与 SQL CE 数据库配合使用,但它的功能并不像 SQL Express 那样全面。然而,有很多好的工具可以填补这些空白。请查看 Erik Jensen 的博客以获得详细概述。
一切 SQL Server Compact
另请查看他的用于将 SQL Express 数据库迁移到 SQL Compact 的工具:
如何将 SQL Server 数据库迁移/缩小到 SQL Server Compact 4.0(和 3.5)
最后看一下这个 SO 问题,了解两种产品之间的更多背景信息:
SQL Server Compact 有哪些限制? (或者 - 如何选择在 MS 平台上使用的数据库?)
For a standalone desktop product it is certainly a lightweight option to consider over SQL Express.
However there are differences between the two to be aware of other than just connection strings. For example SQL CE does not support stored procedures, user-defined functions, or triggers. Additionally it does not support the full range of datatypes that Express supports. On a technical level it also runs in process with your application.
Another consideration is that while SSMS will work with SQL CE databases, it's not as fully featured as it is with SQL Express. There are however a whole raft of good tools out there for filling these gaps. Take a look at Erik Jensen's blog for a good overview.
Everything SQL Server Compact
Also check out his tool for migrating SQL Express databases to SQL Compact:
How to Migrate/Downsize a SQL Server database to SQL Server Compact 4.0 (and 3.5)
Finally take a look at this SO question for more background between the two products:
What are the limitations to SQL Server Compact? (Or - how does one choose a database to use on MS platforms?)
我最近使用它,顺便说一下,我所知道的关于使用它们的事情是 SQL Express 有一个要连接的服务器,并且 Compact 是一个 sdf 文件,所以您必须更改的第一件事是它的连接字符串。
在这次更改之后,没有更多的重大更改要做,我记得,compact几乎拥有express服务器可用的所有指令,因此,这不会有太大问题。
有关详细信息,请参阅 Microsoft 文档,或访问 Wikipedia。
再见。
I worked recently with it, by the way the things I know about using them is that SQL Express has a server to connect to, and, Compact is a sdf file, so the first thing you will have to change is the connection string to it.
After this change, there are no more heavy changes to be done, I remember, compact has almost all the instructions of the express server available, so, it could not be much problem.
Take a look at Microsoft documentation for more information, or at Wikipedia.
See you.
我会投票反对 SQL CE:
我的建议是:
两个数据库都可以 XCOPY 部署,就像 SQL Server Compact Edition 一样。
I would vote against SQL CE:
My recommendations would be:
Both databases can be XCOPY deployed, just like SQL Server Compact Edition.
SQL CE 与 Express 具有相同的大小限制,因此您应该很好。
至于在两者之间移动,我发现 this 用于在 Express 数据库和紧凑的 3.5 数据库。那么我认为您只需要更改 连接字符串 (而不是指向主机/实例,您指向转换后的文件)。有不同的功能 但是,在两者之间,因此您可能必须更改原始数据库中的架构才能顺利进行转换。
SQL CE has the same size limitation as Express, so you should be good.
As far as moving between the two, I found this for moving between express databases and compact 3.5 databases. Then I think you'll only have to change your connection strings (instead of pointing at a host/instance, you point at the converted file). There are different features between the two, though, so you might have to change your schema in the original database for the conversion to go smoothly.