This project is read-only.

Connection string spatialite from Access

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

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"
debug.print "succes"
end if

I got error 308 No Error...

Do you have an idea how I can do this ?

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

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 with just
           Dim cnx As String = "Data Source=" & .<db file name>
                .connSq = New SQLiteConnection(cnx)
I installed libspatialite 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
            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

Nov 19, 2015 at 1:19 PM

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"
debug.print "succes"
end if
Marked as answer by pmeems on 1/21/2016 at 7:55 AM