Connection string spatialite from Access

Oct 8, 2015 at 9:42 AM
Edited Oct 8, 2015 at 9:49 AM
Hello

I am trying to use OgrDataSource from Access to add a layer from spatialite database but I don't find the connextion string...
I tried this :

dim ds as New MapWinGis.OgrDataSource
cnsSpatialite = "Driver=SQLite3 ODBC Driver;Database = C:...\db.sqlite;"
if ds.Open(cnxSpatialite) = false then
debug.print "erreur"
else
debug.print "succes"
end if

I got error 308 No Error...

Do you have an idea how I can do this ?
Thank's

Guen
Oct 13, 2015 at 10:19 AM
no idea...? please...I would like to use this ocx but I can only use spatialite....
Oct 13, 2015 at 11:04 AM
Edited Oct 13, 2015 at 11:06 AM
Hi,

I just began using spatialite and did not reach the point to add a layer, here is what I've done so far, if this can help (or if wrong, anyone let me know !)

I was able to connect using system.data.sqlite with just
           Dim cnx As String = "Data Source=" & .<db file name>
            Try
                .connSq = New SQLiteConnection(cnx)
                .connSq.Open()
I installed libspatialite http://www.gaia-gis.it/gaia-sins/windows-bin-x86/ and installed mod_spatialite-4.3.0a-win-x86.7z library (make sure copy to true in order they get into compile folder)

this allows you to manage your spatialite database and insert démo features
http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/metadata.html
            sql_exec_sq("SELECT load_extension('mod_spatialite.dll');", context.connSq, True)
            sql_exec_sq("SELECT InitSpatialMetaData();", context.connSq, True)
            sql_exec_sq("CREATE TABLE test_geom (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL,  measured_value DOUBLE NOT NULL);", context.connSq, True)
            sql_exec_sq("SELECT AddGeometryColumn('test_geom', 'the_geom',  4326, 'POINT', 'XY');", context.connSq, True)
            sql_exec_sq("INSERT INTO test_geom(id, name, measured_value, the_geom)  VALUES (NULL, 'first point', 1.23456, GeomFromText('POINT(1.01 2.02)', 4326));", context.connSq, True)
Let me know when you'll be able to add the layer.

For gdal, I saw that I have to add libgdal but didn't have time to study so far, so I'll appreciate any follow on examples
http://www.gdal.org/drv_sqlite.html

Olivier
Nov 19, 2015 at 1:19 PM
Hello

It was so easy !!! I tied to do something more complex...
This way works very well :
dim ds as New MapWinGis.OgrDataSource
if ds.Open("C:\temp\mabase.sqlite") = false then
debug.print "erreur"
else
debug.print "succes"
end if
Marked as answer by pmeems on 1/21/2016 at 7:55 AM