Results 1 to 21 of 21

Thread: [RESOLVED] SQLite3

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Resolved [RESOLVED] SQLite3

    Hi all,

    I am at complete wits' end. I just cannot get a working demo using sqlite3. I am thwarted either by broken links, demos not running, my casual knowledge of VB....

    Can someone give me a pointer to a solid, simple, working demo using data controls? All I need to do is read records from a few tables of a SQLite3 database.

    Thanks.

  2. #2
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    Re: SQLite3

    how far can you get with this stuff

    can you connect to a db

    can you create and delete tables

    can you insert into a table

    can you select from a table

    these are the simple tasks you need to master

    its the same for all sql databases

    here to help

    have you tried here

    http://zetcode.com/db/sqlitevb/

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Quote Originally Posted by incidentals View Post
    how far can you get with this stuff

    can you connect to a db
    I've got nothing. I've gotten v2 demos to work but the db's of interest are v3.

    I've got sqlite3.dll, I can't find a reference to all the calls I can make to it. I can see all the entry points but the parameters would just be a guess.

    Other demos use different dll's but for whatever reasons none of them run in the IDE.

    So just a simple example is all I need.

    Thanks.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,734

    Re: SQLite3

    Have a look at www.vbrichclient.com

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Quote Originally Posted by Arnoutdv View Post
    Have a look at www.vbrichclient.com
    Thanks for the link Arnoutdv. However, there is nothing there telling you how to use it. That is what I am running into everywhere - what appear to be promising tools with no help on how to use it, or what appear to be good tools with help only to be a broken link.

    I've run into a method that will work but is very clunky - converting the database to v2 via command line:

    sqlite3 inputfile.db .dump | sqlite outputfile.db

    With a v2 database I can now use the dll AGS_SQLite.dll as demonstrated nicely here:

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

    So that is what I am/was looking for - a v3 dll with a simple explanation as to how to call it.

    Thanks.

  6. #6
    Hyperactive Member
    Join Date
    Jul 2013
    Posts
    402

    Re: SQLite3


  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Quote Originally Posted by Carlos Rocha View Post
    Thanks for the info Carlos.

    I've been through those, been through them all it seems, and they highlight exactly the difficulties I am having.

    The two photo demos crash in my VB6, complaining something about an ActiveX control.

    One link is using ODBC, which I don't want.

    Treeview is based on Jet.

    The github stuff is still lacking any info as to how to use the dll, as is its webpage for the vbrichclient.

    So this isn't so simple, the info just isn't quite there.

    Thanks.

  8. #8
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: SQLite3

    Quote Originally Posted by carpboy View Post
    Thanks for the info Carlos.
    I've been through those, been through them all it seems, and they highlight exactly the difficulties I am having.
    The two photo demos crash in my VB6, complaining something about an ActiveX control.
    I'd stop right here - and want to ask you, what problem you had *exactly*, whilst trying to
    run the demo under the following link:
    http://www.vbrichclient.com/Download...DemoSQLite.zip

    Note, that the Demo in question does not reference any external ActiveX-*Control* -
    its only COM-reference is that to a Dll (vbRichClient5) - and if you don't register
    this COM-Dll properly beforehand, nothing which depends on it will work...

    The above PhotoDemo-zip also contains a Readme.txt where is stated:
    Code:
     
      It (the Demo) depends on the SQLite-wrapper which comes with the RichClient-Framework
      (download from: http://www.vbRichClient.com/#/en/Downloads.htm)
    Then - furthermore, in the Download-Section of vbRichClient.com is clearly explained:
    Code:
     
      Out of the contained dlls you'd have only:
      vbRichClient5.dll   <-- this one here to register (per regsvr32 in Admin-Mode) 
      vb_cairo_sqlite.dll
      DirectCOM.dll
      In addition, please keep those Dlls always together in their Folder - also when you deploy them with your App.
    Quote Originally Posted by carpboy View Post
    So this isn't so simple, the info just isn't quite there.
    Given what I've just posted above, that's not quite true - the PhotoDemo-example above
    is a nice one, because it is still very simple - and because it demonstrates similarities
    to ADO, referring to a "twin-like"-ADO/JET-Demo, written by dilettante, so you can compare
    with ADO-based code (Connections and Recordsets) yourself - in short: if you know how to
    work with ADO-recordsets, then you will not have any problems with the vbRichClient-
    SQLite-wrapperclasses (especially the cRecordset-class, since it behaves nearly identical).

    Just get the above linked PhotoDemo-running - and for that you will have to put the 3
    framework-dlls into a path on your developer-machine - and after that register only
    the vbRichClient5.dll. When that is done, you should be able to startup and run at least
    the SQLite-based PhotoDemo without problems - if not so, posting the exact Error-
    message would be very helpful.

    Olaf

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Thanks for taking the time to reply Olaf.

    Quote Originally Posted by Schmidt View Post
    I'd stop right here - and want to ask you, what problem you had *exactly*, whilst trying to
    run the demo under the following link:
    http://www.vbrichclient.com/Download...DemoSQLite.zip
    ActiveX component can't create object.

    This is in form_load, looking to see if the database exists.

    Note, that the Demo in question does not reference any external ActiveX-*Control* -
    its only COM-reference is that to a Dll (vbRichClient5) - and if you don't register
    this COM-Dll properly beforehand, nothing which depends on it will work...
    I have all the dll's present and, reading your post, again started playing with them. The problems I was having prior was when I would try to register vbrichclient5 it kept telling me that it found the file but couldn't find the entry point. I must have done this 6 times. I then moved the dll to \system32 and tried registering it there and that failed with just a generic 'couldn't find module' message.

    So in good faith to your efforts of explaining all this I reattempted as you directed, including registering it in the project folder, and it worked just perfectly fine this time. I certainly can't explain why but rest assured I had tried this over and over and over the last two days.

    When I wrote that the "the info just isn't quite there" I was referring to all references to how to do this, not just your part. I have been hit with broken links, VB projects not running, good examples but not v3 SQLite compatible, stuff like that. It has been very frustrating.

    So I will play with your efforts and again, thanks for taking the time to write.

  10. #10
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: SQLite3

    Quote Originally Posted by carpboy View Post
    ActiveX component can't create object.
    This is in form_load, looking to see if the database exists.
    Yes, that's the error one gets, when vbRichClient5.dll is not (yet) properly registered
    per regsvr32.exe on the developer-machine in question.

    Quote Originally Posted by carpboy View Post
    I have all the dll's present and, reading your post, again started playing with them. The problems I was having prior was when I would try to register vbrichclient5 it kept telling me that it found the file but couldn't find the entry point. I must have done this 6 times. I then moved the dll to \system32 and tried registering it there and that failed with just a generic 'couldn't find module' message.
    That's IMO related to the requirement (which was pointed out on the download-page),
    that the 3 Dlls of this MiniFramework need to be kept together in the same Folder.

    Isolating the vbRichClient5.dll from its "satellite-companion-dlls" will make registering-
    attempts fail, because of a "non-delayed-load-dependency" to vb_cairo_sqlite.dll (due
    to a internal typelib that is).

    Quote Originally Posted by carpboy View Post
    So in good faith to your efforts of explaining all this I reattempted as you directed, including registering it in the project folder, and it worked just perfectly fine this time.
    Glad it's working now.

    And you don't have to place the 3 Framework-Dlls in the ProjectFolder of a certain Demo-Project -
    just in *some* fixed Folder on your Dev-machine, where you want to place "shared COMponents" -
    e.g. I'm placing the 3 Dlls on my Test-VMs on C:\RC5\... - followed by registering the
    vbRichClient5.dll within that C:\RC5\-folder. That should be it - and you can forget about the
    framework then (until you are in the phase of preparing a Setup for Redistribution).

    All the Demo-Downloads (any Demo-download which depends on the 3 RC5-Base-Dlls)
    will work directly from e.g.: C:\DemoDownloads\SomeSQLiteOrRC5Demo\Some.vbp, ...
    so there's no need, to place any framework-Dlls within those Demo-Folders - and also no
    need to place the RC5 framework-Dlls within System32 or SYSWOW64.

    Since your memory is still fresh - and there seem to be others as well, who were stumbling over the
    installation of the framework-libs (reporting the same "Error": [ActiveX component can't create object]... -
    what do you think I should change on the WebSites Download-Section, to make the first
    installation-attempt more successful for "RichClient-Newbies"?
    Is the placement of my installation-advice on the site too small (or otherwise not prominent enough) -
    or is the wording not entirely clear - any advise is welcome to make it easier for the "next guy".


    Olaf

  11. #11
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: SQLite3

    Quote Originally Posted by Schmidt View Post
    what do you think I should change on the WebSites Download-Section, to make the first
    installation-attempt more successful for "RichClient-Newbies"?
    Is the placement of my installation-advice on the site too small (or otherwise not prominent enough) -
    or is the wording not entirely clear - any advise is welcome to make it easier for the "next guy".
    How about providing a proper installer in addition to the DIY archive?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  12. #12

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Olaf,

    I'm not certain what could be done to make it any clearer, looking back it is quite obvious you state to have the three all together and register the one. I can't explain what exactly happened to me, god only knows, but it seem pretty apparent what one needs to do.

    One thing that would be cool would be a couple paragraphs of information. I'd like to see what the methods are and how they are invoked, nothing detailed, just a summary.

    Thanks again.

  13. #13
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: SQLite3

    @Bonnie (and the suggestion about an Installer).

    Will see what I can come up with - but if I'd be offered the choice between a *.zip-File and
    and a "setup-executable" - I'd always go with the Zip-file download ...
    Also thought, that registering COM-Binaries (ActiveX-Dlls and OCXes) is part of the daily work
    for any VB-Developer, and thus not a big problem.

    Maybe a good compromise is, to include a small "Install_In_Place.exe" in the Zip (which is then
    automatically executed in elevated mode, due to the "Install-Keyword", and just contains and
    calls the normally "Declared" DllRegisterServer-function of the vbRichClient5.dll.


    Quote Originally Posted by carpboy View Post
    I'm not certain what could be done to make it any clearer, looking back it is quite obvious you state to have the three all together and register the one. I can't explain what exactly happened to me, god only knows, but it seem pretty apparent what one needs to do.

    One thing that would be cool would be a couple paragraphs of information. I'd like to see what the methods are and how they are invoked, nothing detailed, just a summary.
    Aside from VBs Object-Explorer (which can give you a good overview about the Classes - their Methods and Parameters) -
    for SQLite there exists (just adapted to RC5) the large NWind-Demo, which starts with a true JET-File (NWind.mdb) and
    then does a live-conversion on first run (into an SQLite-DB -> NWind.db) ... and then there's a whole lot of simple SubForms
    which either can be used to compare to ADO/JET performancewise - or simply offer some ShowCases (all encapsulated
    within such a single Form) for most of the nice things, SQLite has to offer over JET in addition (as e.g. FullText-Search or
    userdefinable Functions and Collations, InMemory-DBs etc.).

    This larger Demo (about 1MB) is downloadable here:
    http://www.vbRichClient.com/Downloads/SQLiteDemos.zip
    (It's called "Demos", plural, because it also contains a very simple Hello_World-intro-Demo,
    but also a somewhat more advanced Undo-Redo-Demo, which does make use of the fast
    Serializing-feature of the SQLite-Recordsets - and the built-in compression-routines of the RichClient-lib.

    Here's a ScreenShot which shows the Starter-Form of the larger NWind-Demo and what is available over the Sub-Forms:


    With that - and the two other small Demos - one should be able to get up to speed quite fast I think.

    Olaf

  14. #14

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Hi all,

    I've resumed playing with vbrichclient5, my last 'project' was quite successful, thanks to everyone.

    I am trying to use it on x64 now. I've tried everything, running from syswow64, registering with the vbs, they all fail with "invalid access to memory location" when trying to register vbrichclient5.dll. All 3 dll's are together.

    Any ideas?

  15. #15
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: SQLite3

    I've just played that through on a 64Bit-Win8.1 machine, using the following steps:

    - create a new Directory on C: (e.g. C:\RC5\ ... the 3 Framework_Dlls are not really supposed to be placed in System32 or SysWOW64)
    - downdload the latest version from: http://www.vbrichclient.com/#/en/Downloads.htm
    - put (unpack) the complete vbRC5BaseDlls.zip-content into the C:\RC5\ folder
    - doubleclick the script-file: C:\RC5\RegisterRC5inPlace.vbs (the script will request elevation - and then register vbRichClient5.dll)

    As said, I had no problems using these steps, to successfully install the RC5 on that machine.

    Before running the VB6-IDE, you should also make sure, that the VB6.exe-File is switched into
    "run as Admin"-mode (using the appropriate Context-Dialogue, ticking the Checkbox there).

    As for deployment...
    As said, the 3 RC5-Dlls are not really meant to be installed in the System32 or SysWOW64-Folders,
    since you can ensure regfree deployment for (at least) the 3-RC5-Dlls quite easily -
    in a separate Bin-Folder below your App-Path...

    I recently wrote an article, how to ensure this kind of "manifest-free regfree deployment-mode":
    http://www.vbforums.com/showthread.p...rectCOM-Helper

    Olaf

  16. #16

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Olaf,

    As always, thanks for all your work and time.

    For the dll's registering, I re-downloaded the package, deleted every instance of all the 'old' ones that I could find, unregistered everything, and it now works just fine.

    My next issue is how does one close the connection? The program crashes on exit. I've narrowed it down to once the connection is made, the END statement doesn't end it all nicely.

    I don't see any methods, that I can find, that seem to do this.

    Thanks again Olaf.

  17. #17
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,891

    Re: SQLite3

    You should never use End to end your programs - here's a decent overview as to why not: http://www.vbforums.com/showthread.p...%29-a-bad-idea

    To close a connection, set the object to Nothing (e.g. Set cnn = Nothing)

    To end your program cleanly, release any form references held in variables (that is, set them to Nothing as above), and unload all loaded forms.

  18. #18
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: SQLite3

    There should be a .Close method on the connection object... once it's closed, then you set it to nothing.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  19. #19
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,891

    Re: SQLite3

    The vbRichClient5 cConnection object doesn't have a Close method (like the ADODB.Connection object for example). Just setting the object to Nothing will close the connection though.

  20. #20

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    14

    Re: SQLite3

    Quote Originally Posted by jpbro View Post
    To close a connection, set the object to Nothing (e.g. Set cnn = Nothing)
    Thanks man, that was it exactly.

  21. #21
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,891

    Re: SQLite3

    Great, glad to help! You can now help others by marking the thread resolved (Click the Thread Tools link above the top post, and then click Mark Thread Resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width