database 在 VB6 中使用 SQLITE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/111285/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 06:57:26  来源:igfitidea点击:

Using SQLITE with VB6

databasesqlitevb6ado

提问by Manuel Ferreria

I am currently using an MSAccess mdb file for a redistributable app.

我目前正在将 MSAccess mdb 文件用于可再发行应用程序。

A while ago I found out about SQLite, as an alternative to my solution, but the binaries they provide do not offer the possiblilty of using them as an object in VB6. (Or at least I couldn't figure it out how).

不久前,我发现 SQLite 作为我的解决方案的替代方案,但它们提供的二进制文件并没有提供将它们用作 VB6 中的对象的可能性。(或者至少我无法弄清楚如何)。

Does anyone has a link, or could write a little about connecting to a SQLite DB from VB6, and its differences with using ADO?

有没有人有链接,或者可以写一些关于从 VB6 连接到 SQLite DB 的内容,以及它与使用 ADO 的区别?

采纳答案by Ben Hoffstein

Here is a link with code examples:

这是包含代码示例的链接:

http://www.freevbcode.com/ShowCode.asp?ID=6893

http://www.freevbcode.com/ShowCode.asp?ID=6893

回答by AngryHacker

I've been working on a VB6 app with SQLite for a while and I've tried a couple of methods of connecting.

我一直在使用 SQLite 开发 VB6 应用程序,并且尝试了几种连接方法。

So let me summarize and give, what in my opinion is, the best answer.

所以让我总结一下,并给出我认为最好的答案。

Methods mentioned by Ben Hoffstein, gobansaor and David W. Fenton are good, but they rely on proprietary interfaces to sqlite.

Ben Hoffstein、gobansaor 和 David W. Fenton 提到的方法很好,但它们依赖于 sqlite 的专有接口。

OLEDB provider by CherryCity is good because it's using a standard interface, but they have a per installation royalty system, which makes it really, really expensive. And their website does not state upfront that the product has royalties. You only find out when you actually bought the product for development and want to distribute it.

CherryCity 的 OLEDB 提供商很好,因为它使用标准接口,但他们有按安装收费的系统,这使得它真的非常昂贵。而且他们的网站没有预先声明该产品有版税。您只有在实际购买用于开发的产品并想要分发它时才会发现。

Finally there is the absolutely free as in both beer and speech, SQLite ODBC driver at http://www.ch-werner.de/sqliteodbc/. It works pretty well and I haven't encountered any major issues just yet. The only minor issue I've encountered is that it won't allow multiple statements in one call, so you just have to separate it. In addition, the driver allows the DSN-less approach, which makes everything so much easier.

最后,在http://www.ch-werner.de/sqliteodbc/ 上有完全免费的啤酒和语音 SQLite ODBC 驱动程序。它工作得很好,我还没有遇到任何重大问题。我遇到的唯一小问题是它不允许在一次调用中包含多个语句,因此您只需要将它分开。此外,驱动程序允许无 DSN 方法,这使一切变得更加容易。

So, imo, the ODBC driver is really the best solution.

所以,imo,ODBC 驱动程序确实是最好的解决方案。

回答by gobansaor

Or try DHSqlite http://www.thecommon.net/2.htmlfrom Datenhaus..

或者尝试来自 Datenhaus 的DHSqlite http://www.thecommon.net/2.html..

"...developed as a fast alternative to ADO, encapsulating the super-fast SQLite-engine..."

“...作为 ADO 的快速替代品而开发,封装了超快的 SQLite 引擎...”

"...With only two Dlls you get a complete Replacement to the whole ADO/JET-environment - no dependency-hazzle anymore..."

“......只需要两个 Dll,你就可以完全替换整个 ADO/JET 环境——不再有依赖关系......”

..it's free (but not opensource).

..它是免费的(但不是开源的)。

回答by Robert French

Just an FYI on this topic/question ...

只是关于这个主题/问题的仅供参考......

The FreeVB code link posted uses AGS_SQLite.dll which only supports SQLite 2.x (limited functionality)

发布的 FreeVB 代码链接使用 AGS_SQLite.dll,它仅支持 SQLite 2.x(功能有限)

The DHSqlite link provided supports SQLite 3.x as well and is a better recommendation for anyone doing SQLite development with VB6 (Classic) ... There are code examples for this SQLite engine at http://www.thecommon.net/3.html

提供的 DHSqlite 链接也支持 SQLite 3.x,对于使用 VB6(经典)进行 SQLite 开发的任何人来说,这是一个更好的建议...... http://www.thecommon.net/3 上有此 SQLite 引擎的代码示例。 html

Hope that helps!

希望有帮助!

回答by stenci

The COM Wrappers / Visual Basic DLLssection at the middle of this pagelists some solution usable with VB6.

本页中间的COM 包装器/Visual Basic DLL部分列出了一些可用于 VB6 的解决方案。

And yes, I'm still stuck developing with VB6 :(

是的,我仍然坚持使用 VB6 进行开发 :(

回答by UuDdLrLrSs

It appears to be possible to directly access the SQLite functions in sqlite.dllusing VB Declare Subor Declare Functionsyntax.

似乎可以sqlite.dll使用 VBDeclare SubDeclare Function语法直接访问 SQLite 函数。

An example which does this is shown here: https://github.com/RobbiNespu/VB6-Sqlite3

执行此操作的示例如下所示:https: //github.com/RobbiNespu/VB6-Sqlite3

Key extract:

关键摘录:

Public Declare Sub sqlite3_open Lib "sqlite.dll" (ByVal FileName As String, ByRef handle As Long)
Public Declare Sub sqlite3_close Lib "sqlite.dll" (ByVal DB_Handle As Long)
Public Declare Function sqlite3_last_insert_rowid Lib "sqlite.dll" (ByVal DB_Handle As Long) As Long
Public Declare Function sqlite3_changes Lib "sqlite.dll" (ByVal DB_Handle As Long) As Long
Public Declare Function sqlite_get_table Lib "sqlite.dll" (ByVal DB_Handle As Long, ByVal SQLString As String, ByRef ErrStr As String) As Variant()
Public Declare Function sqlite_libversion Lib "sqlite.dll" () As String
Public Declare Function number_of_rows_from_last_call Lib "sqlite.dll" () As Long
...
query = "SELECT * FROM users"

row = sqlite_get_table(DBz, query, minfo)

(I do not know if that example is really ready for production code).

(我不知道该示例是否真的准备好用于生产代码)。

回答by Ulises

The vbRichClient-Framework (currently at Version 5), is a free available Set of 3 Dlls: vbRichClient5.dll vb_cairo_sqlite.dll DirectCOM.dll The vbRichClient5.dll is written in VB6 - and a later Open-Sourcing under LGPL is planned.

vbRichClient-Framework(目前为第 5 版)是一套免费的 3 个 Dll: vbRichClient5.dll vb_cairo_sqlite.dll DirectCOM.dll vbRichClient5.dll 是用 VB6 编写的 - 并且计划在 LGPL 下进行以后的开源。

Its main-purpose is, to decouple from as many MS-COM-dependencies as possible, with the goal in mind, to achieve a self-hosting state easier later on, when the accompanying (VB6-compatible) Compiler will lift off. And if easier to achieve platform-portability (for the Compiler and the new Class-based Runtime) is the goal, then we need to start working with such a decoupling-framework already in the transition- and planning-phase.

它的主要目的是尽可能多地与 MS-COM 依赖项解耦,并牢记目标,以便稍后在随附的(与 VB6 兼容的)编译器启动时更容易地实现自托管状态。如果目标是更容易实现平台可移植性(对于编译器和新的基于类的运行时),那么我们需要在过渡和规划阶段开始使用这样一个解耦框架。

So, the lib offers a modern GUI-Framework which works Vector-based, using the cairo-library under the hood (no GDI/GDI+ or DirectX here ... and also nothing of the MS-CommonControls.dll is touched).

因此,该库提供了一个基于矢量的现代 GUI 框架,使用引擎盖下的 cairo 库(这里没有 GDI/GDI+ 或 DirectX ......也没有触及 MS-CommonControls.dll)。

The other larger part, which is often needed and used within "typical VB-Applications" is easy DB-Access (usually done over an accompanying Desktop-DB-File in *.mdb-Format). So what the framework also offers, is an easy to use (and nearly ADO-compatible) replacement for the MS-JET-Engine. This is, what makes up the other larger part of the accompanying satellite-binary: vb_cairo_sqlite.dll ... the SQLite-engine.

在“典型的 VB 应用程序”中经常需要和使用的另一个较大的部分是简单的 DB-Access(通常通过 *.mdb 格式的附带桌面 DB 文件完成)。因此,该框架还提供了一个易于使用(并且几乎与 ADO 兼容)的 MS-JET-Engine 替代品。这就是构成随附卫星二进制文件的另一个较大部分的内容:vb_cairo_sqlite.dll ... SQLite 引擎。

http://www.vbrichclient.com/#/en/Downloads.htm

http://www.vbrichclient.com/#/en/Downloads.htm