Re: SQLite and VB6 - Documentation?
- From: "Schmidt" <sss@xxxxxxxxx>
- Date: Sun, 31 May 2009 16:09:34 +0200
"Webbiz" <nospam@xxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:4ar225dmrms5i4hv0f9taq5ck5ehr375fo@xxxxxxxxxx
I've been plowing through a lot of code the last few weeksThe engine behind the wrapper is always then involved,
of examples of programming for SQLite using the
dhRichClient3 wrapper.
While copying parts of code into a project is not a big deal, I'm
still very foggy as to where SQLite starts and the wrapper ends.
as soon as you specify SQL-*Strings* in some Method-
Parameters.
Cnn.OpenRecordset(SQLString)
Cnn.Execute SQLString
Cnn.CreateCommand(SQLString)
and also implicit (using SQL-commands under the hood)
in these methods:
Rs.UpdateBatch
CommandObject.Execute
Cnn.BeginTrans
Cnn.CommitTrans
Cnn.RollbackTrans
For example, everytime I do a search on SQLite to learnYep - you should concentrate on (and extract) the used SQL-
as much as I can about it, most of the examples are in
programming languages that I'm not familiar with and not VB.
This makes following the examples difficult.
strings in these examples.
Many of the (C- or Python-) examples involve looping over
the single records (in read direction) using a DB-cursor directly.
This loop over-all-single-QueryRecords is encapsulated
inside the Cnn.OpenRecordset-method - and delivers always
a completely filled-up copy (inside the internal Rs-Structures)
as an InMemory-"2D-table". So my wrapper-Recordsets
are handled similar to ADO-Rs, which are retrieved with
"adUseClient" - the clientside RecordCursor is then available
for DB-independent looping directly on the Recordsets
internal InMemory-structures.
Since such an Rs contains table-like data-results, you
can use this content either array-like (over the Rs-Method
ValueMatrix(RowIdx,ColIdx) - but you can also build
new tables from it over Cnn.CreateTableFromRsContent
with only one line of code if you want that.
But also the normal Client-Cursor-Usage is possible as in ADO:
Do Until Rs.EOF
'access the fields of the current record here
For Each Fld in Rs.Fields
debug.print Fld.Value
Next Fld
Rs.MoveNext 'shift the internal Rs-Cursor
Loop
So when I see something like Set Cnn = New_c.Connection,The wrapper is an Object-encapsulation of the engine -
I assume this is to open a connection to the DB, but is this a
SQLite command or wrapper command?
and to be able to use VB-Objects in your Code, you will
always need to instantiate them first.
Either normally over VBs New-Operator:
Set Cnn = New cConnection
or registryfree (requires no registration of dhRichClient3.dll)
Set Cnn = New_c.Connection
New_c is a helping constructor-object, which is delivered
(and defined as a Public Property) in a helper-*.bas-module,
which is only (mainly) there for regfree instancing.
Until here, we talked not about SQLite in special, but about
VB-Objects and their creation (instantiation) in common.
VB-Objects (and the appropriate Class-Definitions, where
one defines their functionality) are nice to use encapsulations
of methods and properties, offering also intellisense-support
in the IDE. In case of the encapsulation of the SQLite-engine-
functionality I made use of VBs power (in terms of RADishness)
to give you an easier Object-view at the flat SQLite-API,
which you see used in many of the online-examples.
In many cases you only need ca. one third of the lines of code
(or even less), to achieve the same effect with the VB-(object)
wrapper.
And why is there an underscore "_" in New_c.Connection?As said above, the New_c is only a *.bas-module-defined
Public Property, which returns a RichClient-Helper-Object
of the Type cConstructor.
I've named it in the way you see it now, to make it more obvious
for "regfree-beginners", that the effect one achieves using it,
is the same as if you'd have used: Set Cnn = New cSomething.
If you have no real interest (because you don't plan to deploy
your solutions) in regfree instancing, then forget the helper-
module and New_c for the moment and use VBs normal
New-Operator for instantiation of RichClient-Objects.
This normal approach works of course only, when the AX-Dll
(dhRichClient3) is properly registered on a given system.
I know these are VERY BASIC questions for DB experts here,Maybe concentrate about learning SQL first - SQLite supports
but I'm not one and really trying to understand what is what.
a very wide range of Standard-SQL-92 - take for example the
simple View-Editor, which is contained in the SQLite-VBDemo.
Maybe ripp it off from the larger Demo (it is basically only
contained in a single VB-Form) - make it work in a small
standalone VB-Project. Take the Nwind.db, which defines
a nice subset of well-related tables - and take a look at the
already defined NWind-Views within the running View-Editor.
Views are basically only predefined, "named SQL-Statements"
for the read-direction.
So try to understand Views first - and how to define more
complex SQL-statements than only plain "Select * From Table".
Write simple Joins, or experiment with the Where clause
first, then with Order By, then with Aggregate-Functions etc.
Unfortunately, I cannot find any documentation that TEACHESThe wrapper is also written as a replacment for ADO/JET.
a person how and what to do to write programs with VB to
deal with SQLite.
ADO is the Object-Layer (in the same way as you use the
Cnn-, Rs-, and Cmd-Objects currently from the RichClient).
And JET (the engine) is more or less hidden to you (it's a set
of Dlls, which does basically the same as sqlite36_engine.dll).
So I dont' have the 'reasons' for what each line of exampleSince the Object-structure and also the Method-naming is
code is for other than knowing it is there and I can simply
copy it. I'd rather KNOW what I'm doing rather than just
'copy' code.
90% similar to ADO (Connections, Recordsets, etc), you
are well advised, if you take a look at VB6-ADO-Examples -
how is dealt there with the ADO-Objects and the Methods
in "Cnn", or "Rs" (I'd recommend NWind.mdb based examples
or tutorials, since you already have both DBs NWind.mdb and
also the SQLite-version (NWind.db).
The web should be full with good descriptions regarding
ADO-usage. Most smaller examples should be copy- and
pastable and then work with some smaller adaptions directly
also with the SQLite-wrapper.
Mainly the Ado-Connection-String-stuff you can skip
and just try the example with an InMemory-DB-Connection
in SQLite - or if you need a FileDB, then just do:
Cnn.CreateNewDB FileName
or
Cnn.OpendDB FileName 'in case the SQLite-DB is already there
With a wrapper such as dhRichClient3.dll, are ALL THEAs long as you don't use VB-Declares against sqlite36_engine.dll,
COMMANDS in my VB code actually wrapper
commands/functions?
then yes - everything goes "through" the wrapper-classes, which
internally use sqlite36_engine.dll directly of course.
Is there anywhere that actually states what these functions/As already statet above - what is sent to the engine itself,
commands are doing 'underneath' the wrapper so that I can
learn what it is sending to SQLite DB itself?
are basically the SQL-Text-Statements (Params).
Or do my questions not make sense to begin with?IMO not, since they are similar to questions of an ADO-
user who now wants to use the JET-engine-Dlls directly
with the plain and flat JET-APIs over VB-Declares.
And such questions don't come up from ADO-users,
since MS's intention was, to hide that flat API from direct
usage (as said, see how the *ADO* or DAO-objects are
used, to talk with your DB in a more comfortable way).
...this is all still very vague to me and I've spent a lot ofDue to the high similarities between the ADO-Classes and
time on this and feel my progress is REALLY slowed by
lack of documentation VB-style.
the (DB-)Classes in the RichClient, you can reuse your
ADO-knowledge by a large amount. If this ADO-knowledge
is not (yet) there on your side, then study more ADO-examples
which are good documented. This way you have a better
feeling, that you don't learn something, which binds you
to only my wrapper once and forever - once you are "fit"
with my wrapper-objects, then you can reuse that knowledge
also in ADO-scenarios and vice versa.
That does not mean, that I will not give you detailed answers
about everything what's going on under the hood of a single
Wrapper-Method - but please ask these questions then in
the context of a concrete example, on what you want to
accomplish. One after the other - maybe we can both build up
a nice "FAQ" this way over time (since you really start from the
ground, so that is a good occassion) - I could copy the extracts
then from here into the Docu-project which will start later
this year on www.thecommon.net.
So, yeah - go on...keep asking... :-)
Olaf
.
- Follow-Ups:
- Re: SQLite and VB6 - Documentation?
- From: Webbiz
- Re: SQLite and VB6 - Documentation?
- References:
- SQLite and VB6 - Documentation?
- From: Webbiz
- SQLite and VB6 - Documentation?
- Prev by Date: Re: Creating Recordset
- Next by Date: Re: Creating Recordset
- Previous by thread: SQLite and VB6 - Documentation?
- Next by thread: Re: SQLite and VB6 - Documentation?
- Index(es):
Relevant Pages
|