如果未安装 SQL Server 2005,我可以创建并连接到 SQL Server CE 数据库吗?
有什么办法可以做到这一点吗?
更新:抱歉,我应该包含更多信息。我正在尝试使用在 PC 上运行的 C# 中的 System.Data.SqlServerCe 创建并连接到 SQL CE 数据库(即不在 Windows Mobile 设备上运行)。
此代码:
string connstr = "Data Source=\"" +
filename + "\";Persist Security Info=False;";
System.Data.SqlServerCe.SqlCeEngine engine = new SqlCeEngine(connstr);
engine.CreateDatabase();
... 在任何安装了 SQL Server 2005 的 PC 上都可以正常工作,但在任何未安装 SQL Server 2005 的 PC 上都会失败。我试图找出是否有任何方法可以在计算机上不安装 SQL Server 2005 的情况下使其正常工作。
Is there any way to do this?
Update: Sorry, I should have included more information. I am trying to create and connect to a SQL CE database using System.Data.SqlServerCe
in C# running on a PC (i.e. not running on a Windows Mobile device).
This code:
string connstr = "Data Source=\"" +
filename + "\";Persist Security Info=False;";
System.Data.SqlServerCe.SqlCeEngine engine = new SqlCeEngine(connstr);
engine.CreateDatabase();
... works fine on any PC that has SQL Server 2005 installed, but fails on any PC that doesn't have it installed. I'm trying to find out if there's any way to get this to work without installed SQL Server 2005 on the machine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Visual Studio 来完成此操作 - 添加连接时,将数据源从 Microsoft SQL Server 更改为 Microsoft SQL Server Compact 3.5。
另外,如果您指的是实际的服务器(而不是管理工具),那么 SQL Server 2008 Management Studio [Express] 可以直接打开 SQL CE 数据库。
编辑:要在 Visual Studio 中创建数据库,请在添加新项目时选择“本地数据库”。那是一个SQLCE 数据库。在 SSMS[E] 中,当您选择 SQL Server Compact 选项时,您可以在数据库文件下拉列表中选择“新建数据库”作为选项。
Edit2:为了让针对 SQL CE 编写的代码在普通目标计算机上成功运行,您需要在其上安装某些东西,尽管不是 SQL Server 2005。SQL CE 是一个单独的产品(下载页面)。如果/当您为产品创建 MSI 安装程序时,它也应该在 Visual Studio 中显示为可再发行模块。
You can do it with Visual Studio - when you add a connection, change the data source from Microsoft SQL Server to Microsoft SQL Server Compact 3.5.
Also, if you mean the actual server - as opposed to the management tools - then SQL Server 2008 Management Studio [Express] can open SQL CE databases directly.
Edit: To create the database in Visual Studio, choose "Local Database" when you go to add a new item. That's a SQLCE database. And in SSMS[E], when you choose the SQL Server Compact option, you can choose "New Database" as an option in the Database File drop-down.
Edit2: In order to have code written against SQL CE run successfully on a vanilla target machine, you will need to install something on it, although not SQL Server 2005. SQL CE is a separate product (download page). It should also appear as a redistributable module in Visual Studio if/when you create an MSI installer for your product.
我认为您的意思是您可以使用工具而不是代码来创建一个。 Studio 只需转到服务器资源管理器并添加新连接即可创建它们(您将获得创建连接的选项)。
如果您正在寻找更好的东西或不需要 Studio 的东西,那么 Primeworks 的数据端口控制台 是一个非常好的工具。
编辑
如果您需要通过代码创建它,那么是的,您仍然可以在不安装服务器的情况下执行此操作。确保您已将 SQL CE Redistributable 二进制文件(适用于正确的 32/64 位)部署到目标并放置在应用程序可以找到它们的位置。
本地查看:
或在线。
I assume that what you mean is can you create one with a tool, rather than with code. Studio can create them just by going to the Server Explorer and adding a new connection (you'll get the option to create one).
If you're looking for something a little nicer or something that doesn't require Studio, then Primeworks' Data Port Console is a really nice tool.
EDIT
If you need to create it through code then yes, you can still do this without Server installed. Make sure that you have the SQL CE Redistributable binaries (for the proper 32/64bit) deployed to the target and in a place the app can find them.
See locally at
or online.
只是添加到 Aaronaught 说,要以编程方式连接到 SQL CE 数据库,您不需要安装 SQL Server。 CE 在 proc 中运行,只要安装了 SqlCE dll(现在它们是框架的一部分),那么您应该能够毫无问题地连接到它。
Just to add to what Aaronaught was saying, to connect to a SQL CE database programmaticaly, you don't either need SQL Server installed. CE runs in proc, and as long as the SqlCE dll's are installed (their part of the framework nowadays) then you should be able to connect to it without any issues.