C# 的便携式数据库
我知道这似乎是一个已经被问过的问题,但我已经尝试了那里的解决方案。
我正在使用 C# 构建一个程序,我需要以每个客户端都有自己的数据库新鲜(动态路径)的方式保存数据。我该怎么做才能让用户不需要安装额外的东西,而只需要安装 .NET 框架?
我听说过 SQLite,但我并没有真正让它发挥作用。
I know that this may seem as a question that was already asked, but I tried the solutions out there already.
I am building a program with C# and I need to save data in a way that every client has his own fresh (dynamic path) to his db. What can I do so users won't need to install extra things, but just .NET framework?
I heard about SQLite, but I didn't really get it working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
SQL Server CE。它在进程内运行,您可以使用应用程序部署所有必需的程序集。请参阅此文章:
如何:部署 SQL Server Compact 3.5 Database with an Application
更新:添加一些我发现有用的其他 SQL Server CE 相关链接:
桌面上的 SQL Server Compact“私有部署”- 概述
将 SQL Server Compact 4.0 与桌面私有部署和安装项目 (MSI) 结合使用(第 2 部分)
使用 ADO.NET 实体提供程序私下部署 SQL Server Compact
Sql Server CE. It runs in-process and you can deploy all required assemblies with your application. See this article:
How to: Deploy a SQL Server Compact 3.5 Database with an Application
Update: Adding some other SQL Server CE related links that I have found helpful:
SQL Server Compact “Private Deployment” on desktop–an overview
Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)
Privately Deploying SQL Server Compact with the ADO.NET Entity Provider
在此处下载 SQLite .NET 数据提供程序,然后从应用程序中引用 System.Data.SQLite.dll。下面的例子应该可以立即运行。
当然,它所做的只是列出指定文件中的表。如果该文件不存在,那么它将自动创建,并且自然不会有任何表在其中。但是,至少它应该可以工作。
Download the SQLite .NET data provider here and then reference System.Data.SQLite.dll from within your application. The following example should work right off the bat.
Of course all it does is list the tables in the specified file. If the file does not exist then it will be created automatically and naturally there will not be any tables in it. But, at the very least it should work.
您可以尝试 SQL Server Compact Edition -
http://weblogs.asp.net/scottgu/archive/2010/06/30/new-embedded-database-support-with-asp-net.aspx
You could try SQL Server Compact Edition -
http://weblogs.asp.net/scottgu/archive/2010/06/30/new-embedded-database-support-with-asp-net.aspx
官方 SQLite 快速入门:
http://www.sqlite.org/quickstart.html
代码示例对于 System.Data.Sqlite,在原始支持论坛上:
http://sqlite.phxsoftware.com/forums/t/76.aspx
您可以在这个相关 SO 问题的答案中找到 SQLite 的一些替代方案:
SQLite 的替代品?
The official SQLite QuickStart:
http://www.sqlite.org/quickstart.html
Code samples for System.Data.Sqlite, on the original support forums:
http://sqlite.phxsoftware.com/forums/t/76.aspx
You can find a few alternatives to SQLite in the answers to this related SO question:
Alternatives to SQLite?
如果我没记错的话,c#.net 可以与 sql 数据库交互,而无需单独的服务器软件。您只需导入 system.data.sqlclient 即可。
SQL 可能适合您,但没有简单的方法来开始使用它的原因是数据库架构不是一个简单的主题。如果您选择走这条路,有很多很棒的书籍可以帮助您入门。它专门讨论 MSSQL 的语法,但 Itzik Ben-Gan 的“T-SQL 基础知识”是一本很有帮助的书。当然,不同 SQL 迭代之间的语法差异是非常常见的,一旦您了解了您碰巧正在处理的 SQL 的特性,就不再是一个巨大的负担。
If I'm not mistaken, c#.net can interface with a sql database without separate server software. You would just import system.data.sqlclient.
SQL could work for you, but the reason that there is no simple way to get started with it is that database architecture is not a simple subject. There are plenty of great books out there to get you started if you choose to go that route. It deals specifically with the syntax of MSSQL, but "T-SQL Fundamentals" by Itzik Ben-Gan is a helpful one. Of course, syntax variations between different iterations of sql are extremely common, and not a huge burden once you know the idiosyncrasies of the one you happen to be dealing with.