Access 数据库引擎的优缺点。 SQLite 之后的生活

发布于 2024-07-16 14:28:17 字数 632 浏览 4 评论 0原文

不久前我问了一个问题,关于哪个本地数据库适合我的情况。 我需要从 .NET 代码和 VB6 访问数据库。 压倒性的反响是 SQLite。 然而,我决定放弃 SQLite,因为它唯一的 OLE DB 提供商对我的软件的每个部署副本收取版税。 它还需要在每台 PC 上运行激活程序。

在评估其他选项(SQL Server Compact 版本 - 几乎无法运行的 OLE DB 提供程序、Firebird - 不想为另一个驱动程序付费等...)之后,我得出的结论是,唯一可行的选择是使用 .由 Microsoft Access(或 Jet 引擎)创建的 MDB 文件。

我从90年代后期就没有使用过它了,所以我有以下问题想请教有使用过它的人。

  1. 他们是否解决了数据库时不时损坏的问题?
  2. 是通过 ADO.NET OLEDB Provider 从 C# 完成对 MDB 的访问,还是有一个本机解决方案(我似乎找不到它)。
  3. 有没有可行的替代方案来替代 Access 中真正蹩脚的 SQL 编辑器?

谢谢。

I asked a question a while ago about which local DB was right for my situation. I needed to access the DB from both .NET code and VB6. The overwhelming response was SQLite. However, I decided to pass on SQLite, because the only OLE DB provider for it charges royalties for every deployed copy of my software. It also requires an activation procedure to be run on every single PC.

After evaluating other options (SQL Server Compact edition - barely functional OLE DB provider, Firebird - don't want to have to pay for another driver, etc...), I've come to conclusion that the only viable choice is using .MDB files created by Microsoft Access (or the Jet engine).

I haven't used it since late 90s, so I have the following questions to those who have experience with it.

  1. Have they resolved the problem where the database would corrupt every now and then.
  2. Is access to the MDB from c# accomplished via the ADO.NET OLEDB Provider or is there a native solution (i can't seem to find it).
  3. Is there a viable alternative to the really crappy SQL Editor in Access?

Thanks.

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

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

发布评论

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

评论(7

用心笑 2024-07-23 14:28:17

我不会“返回”Access,而是坚持使用 SQLite 并使用 System.Data.SQLite 提供程序在 .NET 代码中进行 SQLite 数据访问。

然后,我只需创建一个简单的 COM 互操作 .NET 类,供 VB6 使用,该类包装了任何所需的 SQLite 数据访问功能。 最后,只需像 VB6 项目中的标准 COM 对象一样引用和使用它即可。

我对 Access 的了解可能有点过时,并且因糟糕的经历而产生偏差,但在合理范围内,我会在诉诸 Access 路线之前尝试大多数其他选择。

Rather then going "back" to Access, I'd stick with SQLite and use the System.Data.SQLite provider for SQLite data access within the .NET code.

Then I'd just create a simple COM interop .NET class for use by VB6 that wraps any required SQLite data access functionality. Finally, just reference and use it like a standard COM object from your VB6 projects.

My knowledge of Access is probably a bit dated and biased by bad experiences, but within reason I would try most other options before resorting to the Access route.

辞别 2024-07-23 14:28:17

您是否考虑过SQL Server 2008 Express Edition(而不是SQL Server CE)?

1) 就我个人而言,我发现大多数情况下 Access DB 损坏是由于代码自身未清理,或者涉及到有故障的网卡。

2)

string connectionString = @“Provider = Microsoft.Jet.OLEDB.4.0; " + 
                          @"Data Source = C:\data\northwind.mdb; " +
                          @"User Id = guest; Password = abc123”


using (OleDbConnection oleDbConnection = New OleDbConnection())
{
    oleDbConnection.ConnectionString = connectionString;

    oleDbConnection.Open();

    ...
}

3) SQL Server 2008 Express 版

Have you considered SQL Server 2008 Express Edition (as oppose to SQL Server CE)?

1) Personally, I found that most times that Access DBs corrupted it was due to code that didn't clean up after it self, or there was a faulty Network card involved.

2)

string connectionString = @“Provider = Microsoft.Jet.OLEDB.4.0; " + 
                          @"Data Source = C:\data\northwind.mdb; " +
                          @"User Id = guest; Password = abc123”


using (OleDbConnection oleDbConnection = New OleDbConnection())
{
    oleDbConnection.ConnectionString = connectionString;

    oleDbConnection.Open();

    ...
}

3) SQL Server 2008 Express Edition

怀念你的温柔 2024-07-23 14:28:17

MDB 损坏主要是由于数据库打开时客户端计算机、文件服务器和网络中发生的故障造成的。 如果将 MDB 放在文件共享上,这始终是一种风险,如果放在本地硬盘驱动器上并由一个用户使用,则问题要少得多。

我不希望 SQLite 有任何不同,甚至更糟。

定期运行 JetComp.exe(Microsoft 下载)将修复许多问题并压缩索引表等。 无论您使用什么,备份都很重要。

您根本不需要 MS Access 即可使用 Jet MDB。 有一些第三方工具可用于设计数据库模式和执行交互式查询,包括命令行和 GUI。

MDB corruption is largely due to failures that occur in client machines, file servers, and networks while the database is open. If you put the MDB on a file share this is always a risk, if on a local hard drive and used by one user the problems are much rarer.

I would not expect SQLite to be any different, and if anything worse.

Periodically running JetComp.exe (a Microsoft download) will fix many problems and compact index tables and such. Backups are important no matter what you use.

You don't need MS Access at all to use Jet MDBs. There are some 3rd party tools for designing the database schema and doing interactive queries, both command line and GUI.

并安 2024-07-23 14:28:17

由于 MDB 格式或多或少已被弃用,因此您 90 年代末的知识相当最新。 查看此 MSDN 页面

Since the MDB format is more or less deprecated, your late 90s knowledge is quite up to date. See this MSDN page

尝蛊 2024-07-23 14:28:17

您还可以尝试SQL Anywhere,它可以在各种操作系统上运行并且占用空间较小。 对我有用:)

You could also try SQL Anywhere it runs on various OS and has a small footprint. Works for me :)

嘦怹 2024-07-23 14:28:17

AngryHacker问:

Q1。 他们是否解决了数据库时不时损坏的问题?

呃,什么?

在正确维护的环境中正确部署的正确设计的应用程序中从来不存在任何损坏问题。 我已经三四年没有见过损坏的 MDB,而且我有几十个应用程序在许多不同类型的操作环境中被许多客户全职使用。

我认为大多数遭受损坏的人是那些尝试在许多用户(无论是拆分还是未拆分)之间共享 MDB 文件的人。 由于您没有考虑使用 Access,所以这并不是一个真正的问题。

Q2。 是通过 ADO.NET OLEDB Provider 从 C# 完成对 MDB 的访问,还是有一个本机解决方案(我似乎找不到它)。

本机解决方案是 DAO,但那是 COM,因此您可能不想使用它。 对于 C#,我认为 OLEDB 是您最好的选择,但这不是我的专业领域,因此请持保留态度。 我相信 Michael Kaplan 报道过 Jet ADO/OLEDB 提供程序是线程安全的,而 DAO 则不是。 但这并不意味着他推荐 ADO/OLEDB 而不是 DAO,但他的评论也是来自 Access 上下文,而不是 C#。

Q3。 有没有可行的替代方案来替代 Access 中真正蹩脚的 SQL 编辑器?

当您实际上没有使用 Access 时,为什么要使用它? 您可以使用任何您喜欢的 SQL 编辑器,只要您测试您编写的 SQL 与 Jet 的 SQL 方言兼容即可。

就我而言,我不明白 Access 的 SQL 编辑器有什么问题(除了无法设置字体大小),但是,我使用 QBE 编写了很多 SQL,甚至从来不看SQL 视图。

AngryHacker asked:

Q1. Have they resolved the problem where the database would corrupt every now and then.

Er, what?

There was never any corruption problem in properly engineered apps properly deployed in properly maintained environments. I haven't seen a corrupted MDB in 3 or 4 years, and I have dozens of my apps in full-time production use by many clients in many different types of operating environments.

I think that most people who experience corruption are those who try to share an MDB file among many users (whether split or unsplit). Since you're not contemplating using Access, that's not really an issue.

Q2. Is access to the MDB from c# accomplished via the ADO.NET OLEDB Provider or is there a native solution (i can't seem to find it).

The native solution would be DAO, but that's COM, so you might not want to use that. From C#, I'd say OLEDB is your best bet, but that's not my area of expertise so take it with a grain of salt. I believe that Michael Kaplan reported that the Jet ADO/OLEDB provider was thread-safe, while DAO is not. This doesn't mean he recommended ADO/OLEDB over DAO, though, but his comments also came in an Access context, and not C#.

Q3. Is there a viable alternative to the really crappy SQL Editor in Access?

Why would you be using that when you're not actually using Access? You could use any SQL editor you like as long as you test that the SQL you write is compatible with Jet's SQL dialect.

I, for one, don't see what the issue is with Access's SQL editor (other than the inability to set the font size), but then, I write a lot of my SQL using the QBE and don't ever even look at the SQL view.

李不 2024-07-23 14:28:17

回答你关于 Access 中真正蹩脚的 SQL 编辑器的问题 - 我完全同意。 字体很糟糕,MSAccess 总是错误地重新格式化查询,有时会添加破坏 SQL 的元字符,最后但最糟糕的是,如果它无法解析 SQL,它不会让您访问它!

我的解决方案是使用外部代码。 我使用 DAO 实例化 MSAccess,然后可以使用 QueryDefs 集合直接编辑查询。 它可以让您执行大多数操作 - 创建、重命名、编辑等。但是,有一些操作您无法通过这种方式执行 - 例如,您无权访问查询元数据(描述、隐藏等)。

外部代码也很棒,因为您可以构建一套测试用例,指定预期返回值等。

To answer your question regarding the really crappy SQL editor in Access - I wholeheartedly agree. The font stinks, MSAccess always badly reformats the query, it sometimes adds in metacharacters that break my SQL, and lastly but worstly, if it can't parse the SQL, it won't let you have access to it!

My solution is to use external code. I use DAO to instantiate MSAccess and can then directly edit the queries using the QueryDefs collection. It lets you do most things - create, rename, edit, etc. There are a couple of things you cannot do this way though - for example, you do not have access to the query metadata (description, hidden, etc).

External code is also great because you can build a suite of test cases, specifying expected return values, etc.

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