Question

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

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).

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

Was it helpful?

Solution

Here is a link with code examples:

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

OTHER TIPS

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

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.

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.

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.

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

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

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

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

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

Just an FYI on this topic/question ...

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

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

Hope that helps!

The COM Wrappers / Visual Basic DLLs section at the middle of this page lists some solution usable with VB6.

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

It appears to be possible to directly access the SQLite functions in sqlite.dll using VB Declare Sub or Declare Function syntax.

An example which does this is shown here: 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.

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.

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).

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top