简体   繁体   English

在VB6中使用SQLITE

[英]Using SQLITE with VB6

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. 前段时间我发现了SQLite,作为我的解决方案的替代品,但是他们提供的二进制文件并没有提供将它们用作VB6中的对象的可能性。 (Or at least I couldn't figure it out how). (或者至少我无法弄清楚如何)。

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的区别?

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. CherryCity的OLEDB提供商之所以很好,是因为它使用的是标准接口,但它们有一个每个安装版税系统,这使得它非常非常昂贵。 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. 您只能了解实际购买产品以进行开发并希望分发它的时间。

Finally there is the absolutely free as in both beer and speech, SQLite ODBC driver at http://www.ch-werner.de/sqliteodbc/ . 最后,在http://www.ch-werner.de/sqliteodbc/上有一个完全免费的啤酒和语音,SQLite ODBC驱动程序。 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. 此外,该驱动程序允许采用无DSN方法,这使得一切变得更加容易。

So, imo, the ODBC driver is really the best solution. 所以,imo,ODBC驱动程序确实是最好的解决方案。

Or try DHSqlite http://www.thecommon.net/2.html from 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环境 - 不再依赖于halus ...”

..it's free (but not opensource). ..是免费的(但不是开源)。

Here is a link with code examples: 以下是代码示例的链接:

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

Just an FYI on this topic/question ... 只是关于这个主题/问题的一个FYI ......

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! 希望有所帮助!

The COM Wrappers / Visual Basic DLLs section at the middle of this page lists some solution usable with VB6. 本页中间的COM Wrappers / Visual Basic DLLs部分列出了一些可用于VB6的解决方案。

And yes, I'm still stuck developing with VB6 :( 是的,我仍然坚持用VB6开发:(

It appears to be possible to directly access the SQLite functions in sqlite.dll using VB Declare Sub or Declare Function syntax. 似乎可以使用VB Declare SubDeclare Function语法直接访问sqlite.dll的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). (我不知道这个例子是否真的准备好生产代码)。

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下进行后续的Open-Sourcing。

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. 它的主要目的是,尽可能多地从MS-COM依赖性中解耦,以便在以后更容易实现自托管状态,此时随附的(VB6兼容的)编译器将会解除。 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. 如果更容易实现平台可移植性(对于编译器和新的基于类的运行时)是目标,那么我们需要在转换和规划阶段开始使用这样的解耦框架。

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). 因此,lib提供了一个现代的GUI-Framework,它基于Vector工作,使用引擎盖下的cairo-library(这里没有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). 在“典型的VB应用程序”中经常需要和使用的另一个较大的部分是简单的DB-Access(通常在* .mdb格式的随附Desktop-DB-File上完成)。 So what the framework also offers, is an easy to use (and nearly ADO-compatible) replacement for the MS-JET-Engine. 因此,框架还提供了一种易于使用(并且几乎与ADO兼容)的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_cairo_sqlite.dll ...... SQLite引擎。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM