ArcGIS Engine 连接SQL Server并建立关联

IWorkspaceFactory  pWFactory=new OLEDBWorkspaceFactory();

IPropertySet  pPropertySet=new  PropertySetClass();

pPropertySet.SetProperty(“CONNECTSTRING”,”Provider=SQLOLEDB;DataSource=服务器名;Initial Catalog=数据库名;User ID=用户名;Password=密码;”);

IWorkspace  pWorkspace=pWFactory.open(pPropertySet,0);

IFeatureWorkspace  pFWspace=( IFeatureWorkspace)pWorkspace;

ITable pForeignTable=pFWspace.openTable(“表名”);

//join关联外部表

IMap  pMap=AxMapControl1.Map;

ILayer  pLayer=pMap.layer(0);

IFeatureLayer  pFLayer=( IFeatureLayer) pLayer;

IFeatureClass  pFeatureClass=pFLayer.FeatureClass;

IMemoryRelationshipClassFactory  pMemoRelCFactory=new MemoryRelationshipClassFactoryClass();

IRelationshipClass  pRelationshipClass = pMemoRelCFactory.Open (“TableJoin1”,pFClass,”OBJECTID”,(IObjectClass)pForeignTable,  ”OBJECTID”,  ”forward”,  ”backward”, esriRelCardinality.esriRelCardinalityOneToOne);

IDisplayRelationshipClass  pDisplayRelationshipClass=( IDisplayRelationshipClass)pFlayer;

pDisplayRelationshipClass.DisplayRelationshipClass(pRelClass,esriJoinType.esriLeftOuterJoin);

上一篇:使用Web.Config Transformation配置灵活的配置文件


下一篇:《UNIX网络编程 卷1:套接字联网API(第3版)》——1.6 本书中客户/服务器程序示例索引表