Arc Engine 9.3 连接 SQL Server 2008

  • 来源: 赛迪网 作者: CSDN   2009-08-02/09:08
  • 添加using指令。

    view plaincopy to clipboardprint?
    using ESRI.ArcGIS.esriSystem;   
    using ESRI.ArcGIS.DataSourcesOleDB;  
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.DataSourcesOleDB;

    连接数据库,并打开一张表。

    view plaincopy to clipboardprint?
    PropertySet propertySet=new PropertySet();   
    propertySet.SetProperty("CONNECTSTRING","Provider=SQLOLEDB;
    Integrated Security=SSPI;Persist Security Info=False;
    Initial Catalog=数据库名;Data Source=机器名/服务器名");   
    IWorkspaceFactory2 workspaceFactory = new OLEDBWorkspaceFactoryClass();   
    IWorkspace workspace = workspaceFactory.Open(propertySet, 0);   
    IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace; 
    ITable table = featureWorkspace.OpenTable("表名");

    如果出现HRESULT:0x80040228异常,则应先初始化licensecontrol。


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多