找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 172|回复: 0

连接SDE数据库

[复制链接]

0

主题

0

回帖

26

积分

管理员

积分
26
发表于 2024-3-9 13:40:21 | 显示全部楼层 |阅读模式
连接SDE数据库
void OnTestConnect()
{
// TODO: Add your control notification handler code here
UpdateData();
CGenericClass m采用GenericFun;
IWorkspacePtr ipWS;
m采用GenericFun.connectToSDE(m采用strServer,m采用strService,m采用strUser,m采用strPassword,m采用strDatabase,m采用strConnectVersion,&ipWS);
if(ipWS!=NULL)
{
  AfxMessageBox("Test connection successful");
}
else
{
  AfxMessageBox(m采用GenericFun.GetErrorDescription());
}
}


// openSDEWorkspace:  create and open the sde workspace based on the provided information
//
HRESULT CGenericClass::connectToSDE(CString server,
         CString instance,
         CString user,
         CString passwd,
         CString database,
         CString version,
         IWorkspace ** outWorkspace)
{
if (outWorkspace == NULL)
  return E采用POINTER;

// create the property set for the connection parameters
IPropertySetPtr ipPropertySet;
ipPropertySet.CreateInstance(CLSID采用PropertySet);
// open workspace
IWorkspaceFactoryPtr ipWorkspaceFactory;

// configure the propertyset
if(TRUE)//SQL
{
  ipWorkspaceFactory.CreateInstance(CLSID采用SdeWorkspaceFactory);
  ipPropertySet->SetProperty(CComBSTR("SERVER"),    CComVariant(server));
  ipPropertySet->SetProperty(CComBSTR(L"INSTANCE"), CComVariant(instance));
  ipPropertySet->SetProperty(CComBSTR(L"DATABASE"), CComVariant(database));
  ipPropertySet->SetProperty(CComBSTR(L"USER"),     CComVariant(user));
  ipPropertySet->SetProperty(CComBSTR(L"PASSWORD"), CComVariant(passwd));
  ipPropertySet->SetProperty(CComBSTR(L"VERSION"),  CComVariant(version));
}
return ipWorkspaceFactory->Open(ipPropertySet, NULL, outWorkspace);
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-28 13:31 , Processed in 0.109541 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表