Using Sqlite/Spatialite with ArcObjects and C#

4100
1
06-27-2015 11:43 PM
StevenPaplanus
New Contributor III

I was wondering if there are any samples for interacting with SQLite/spatialite with c#.   I understand how to use the filegdbworkspacefactory that allows me to specify a file to create a workspace, and then from there I can get to the feature classes.  I do not see any workspace factories that seem to support SQLite and Spatialite.  In this case, I need to manipulate several feature classes and geoprocessing functions.  I know how to create the database both in c# ado.net code and arcpy createsqlitedatabase.  But no such luck on accessing the feature classes. In the past, it was simple with the workspace factories, but I need to know how to do it with the SQLite database engine.   Any help or suggestions or links to a code snippet would be appreciated.

Steve Paplanus

0 Kudos
1 Reply
MitchWolberg1
New Contributor

Hi Steven,

here's some code that I use in Delphi which might help. There are limitations with using SQLITE in ArcMap.

SqliteSource is the full file path.

var

  pWrkspcFact   : IWorkspaceFactory ;

  pFtrWrkspc     : IFeatureWorkspace ;

  pDataset   : IDataset ;

begin

      pWrkspcFact := CoSqlWorkspaceFactory.Create as IWorkspacefactory ;

      pFtrWrkspc  := pWrkspcFact.OpenFromFile ( SqliteSource , 0 ) as IFeatureWorkspace ;

      pDataset := pFtrWrkspc.OpenTable ( 'Location' ) as IDataset ;

Mitch Wolberg,

Rockware, Inc.

0 Kudos