Engine中如何连接SQLite数据库?

Engine中如何连接SQLite数据库?
已邀请:

朱新颖

赞同来自:

【解决办法】:
1,ArcMap中创建SQLite数据库,可以使用脚本arcpy.gp.CreateSQLiteDatabase(sqlite_database_path, ST_GEOMETRY) 即可;

2,Engine中连接使用SqlWorkspaceFactoryClass初始化IWorkspaceFactory即可,注意只能新建和导入导出要素类,可以查看,不能编辑。
测试代码如下:


IWorkspaceFactory pWrkspcFact = new SqlWorkspaceFactoryClass() as IWorkspaceFactory ;
             IFeatureWorkspace pFtrWrkspc = pWrkspcFact.OpenFromFile(@D:\test\test.sqlite,0) as IFeatureWorkspace ;
             IFeatureClass pDataset = pFtrWrkspc.OpenFeatureClass(river) as IFeatureClass;
             IFeatureLayer FL = new FeatureLayerClass();
             FL.FeatureClass = pDataset;
             axMapControl1.AddLayer(FL as ILayer);
             axMapControl1.Refresh();

 

要回复问题请先登录注册