Convert Any Database to SQLite (source & exe)

Discussion in 'Code Samples & Tips' started by dzt, May 26, 2007.

  1. dzt

    dzt Active Member Licensed User


    Here is an example of how to convert any database file, with OLEDB provider or ODBC driver, to SQLite, programmatically.

    With a Command Line utility (DB2CSV, VB6 source and executable) you can run any SQL SELECT statement to any database and convert the result to CSV file.

    After that you can convert the CSV file to SQLite database (CSV2SL3, BASIC4PPC source and executable)

    This code is from a field service app I'm developping.

    Attached are two zip files.
    DB2CSV.ZIP: Visual Basic 6 source code and compiled app. Must have MDAC 2.8 installed and VB6 runtime files.
    CSV2SL3.ZIP: Basic4PPC Source code and compiled app. Must have .NET 2.0 installed.



    Attached Files:

    Last edited: May 26, 2007
  2. belotrei

    belotrei Member

    Con.CreateSQLTable ("Table1","mastertablename")

    What is the syntax that needed to be added to the code above if i want to set the data type of certain column when making sql table?
    Ex: i want to set "number" column to numeric.

    So i don't have to reedit the data type of column anymore with third-party application.

  3. tcgoh

    tcgoh Active Member Licensed User


    Hi Dzt,

    Thanks for your above program and answering all the questions on SQL

    However, when I try to compile your CSV2SL3 program to run on Device, it give me " NullReferenceException ". I have even included SQLDevice.dll in this folder with all your files.

    I have run other SQL program(eg. SQL Viewer from Erel) without any problem. ie Net 2.0 is installed.

  4. dzt

    dzt Active Member Licensed User

    Hi tcgoh,

    Actually this program it was made to run on a desktop computer. To combile for PPC you need to:
    1. Copy form C:\Program Files\Anywhere Software\Basic4ppc Desktop\Libraries SQLDesktop.DLL and SQLDevice.DLL.
    2. Tools->Components->Device->Add DLL SQLDevice.DLL
    3. Now it can compile

    And copy to your device the produced EXE, SQLDevice.DLL and from C:\Program Files\Anywhere Software\Basic4ppc Desktop\Libraries\SQLNative\Device the System.Data.SQLite.DLL file.
  5. tcgoh

    tcgoh Active Member Licensed User

    Thanks. I'll try that.
  6. tucano2000

    tucano2000 Active Member Licensed User

    To Create, Edit, Modify table and registers in sqlite 3 I recommend this...

    A program for windows excellent. Is freeware at this moment:

    SQLite Database Browser
  7. tcgoh

    tcgoh Active Member Licensed User

    Hi dzt,

    I'm trying to build a program with sl3. However, I face a few problems with data convertion, could you kindly point me to the right direction:

    1. Your CSV2DLS3 is great, but it sometime give an error on the cmd line "DROP TABLE CUSTS"! (msg - no such table:custs) Can I use another code like clear table? or....

    2. My data file comes from FoxPro, can FoxPro export to sl3 file? if so do I need additional drivers or special codes.

    3. Can Basic4ppc work with sql data file or only with sl3?

    Thanks and regards
  8. JMW

    JMW Member Licensed User

    Anyone know what happened to the second attachment?
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice