Using Sqlite/Spatialite with ArcObjects and C#

3748
1
06-27-2015 11:43 PM
Highlighted
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

Reply
0 Kudos
1 Reply
Highlighted
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.

Reply
0 Kudos