ao能连接oracle吗,配置式AO连接数据库

首先,配置文件,setup.xml

Provider=MSDAORA;Persist Security Info=true;User ID=xxxx;password=xxxx;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxooxooxx)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))

xx

xxooxooxx

5151

xxxx

xxxx

ORCL

SDE.DEFAULT

5

10

其次,读取配置文件,

public static string Get_Xml(string xml_name)

{

XmlDocument xmldoc = new XmlDocument();

xmldoc.Load("./setup.xml");

XmlNodeList nodelist = xmldoc.SelectSingleNode("setup").ChildNodes;//第一个节点

string rusult = nodelist.Item(0).SelectSingleNode(xml_name).InnerText;

return rusult;

}

然后,连接数据库,

private void button3_Click(object sender, EventArgs e)

{

string sdeServer = Get_Xml("SDEServer");

string sdeInstance = Get_Xml("SDEInstance");

string sdeDatabase = Get_Xml("SDEDatabase");

string sdeUser = Get_Xml("SDEUser");

string sdePassword = Get_Xml("SDEPwd");

string sdeVersion = Get_Xml("SDEVersion");

double bufferDis = Convert.ToDouble(Get_Xml("bufferDistance"));

double filterDis = Convert.ToDouble(Get_Xml("filterDistance"));

IWorkspaceFactory sdeWorkspaceFactory;

IFeatureWorkspace workSpace;

try

{

ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

//授权信息加载

ESRI.ArcGIS.esriSystem.IAoInitialize m_AoInitialize = new ESRI.ArcGIS.esriSystem.AoInitialize();

m_AoInitialize.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcInfo);

//进行license控件的初始化

IAoInitialize m_pAoInit = new AoInitializeClass();

m_pAoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer);

IPropertySet propSet = new PropertySetClass();

propSet.SetProperty("SERVER", sdeServer);

propSet.SetProperty("INSTANCE", sdeInstance);

propSet.SetProperty("USER", sdeUser);

propSet.SetProperty("PASSWORD", sdePassword);

propSet.SetProperty("DATABASE", sdeDatabase);

propSet.SetProperty("VERSION", sdeVersion);

sdeWorkspaceFactory = new SdeWorkspaceFactoryClass();

workSpace = (IFeatureWorkspace)sdeWorkspaceFactory.Open(propSet, 0);

// MessageBox.Show("数据库练级成功!");

//得到路段图层

IFeatureClass pFCLuDuan = (workSpace as IFeatureWorkspace).OpenFeatureClass("路段");

IFeatureLayer pFLLuDuan = new FeatureLayer();

pFLLuDuan.FeatureClass = pFCLuDuan;

pFLLuDuan.Name = "路段";

ILayer pLayer = pFLLuDuan as ILayer;

IMap pMap = axMapControl1.Map;

pMap.AddLayer(pLayer);

axMapControl1.ActiveView.Refresh();

}

catch (Exception ex)

{

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值