libertine
路人甲
路人甲
  • 注册日期2006-09-22
  • 发帖数14
  • QQ
  • 铜币189枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1712回复:2

[求助]如何用IP地址连接SDE?

楼主#
更多 发布于:2008-01-10 09:17
<P>在以下的代码中,我用服务器名作为变量csSever的值,则连接成功;</P>
<P>但当我用IP地址作为它的值时,则连接失败。</P>
<P>我想要做一个像Catalog那样,可以写IP做服务器名的,请问该怎么写?</P>
<P>HRESULT ConnectToSDE(IWorkspace **ipSdeWS)<BR>{<BR> //Connecting to SDE<BR> CString csSever,csInstance,csUser,csPasswd,csDatabase,csVersion;<BR> csSever = "ghy-td2kwiodh72";<BR> csInstance = "esri_sde";<BR> csUser = "sde";<BR> csPasswd = "sde";<BR> csDatabase = "";<BR> csVersion = "sde.default";<BR> BSTR server; <BR>    BSTR instance; <BR> BSTR user; <BR>    BSTR passwd; <BR>    BSTR database;<BR> BSTR version;</P>
<P> server = csSever.AllocSysString ();<BR> instance = csInstance.AllocSysString();<BR> database = csDatabase.AllocSysString();<BR> user = csUser.AllocSysString();<BR> passwd = csPasswd.AllocSysString();<BR> version = csVersion.AllocSysString();</P>
<P> IPropertySetPtr ipPropertySet;<BR>    ipPropertySet.CreateInstance(CLSID_PropertySet);</P>
<P> ipPropertySet->SetProperty(CComBSTR("SERVER"),    CComVariant(server));<BR> ipPropertySet->SetProperty(CComBSTR(L"INSTANCE"), CComVariant(instance));<BR> ipPropertySet->SetProperty(CComBSTR(L"DATABASE"), CComVariant(database));<BR> ipPropertySet->SetProperty(CComBSTR(L"USER"),     CComVariant(user));<BR> ipPropertySet->SetProperty(CComBSTR(L"PASSWORD"), CComVariant(passwd));<BR> ipPropertySet->SetProperty(CComBSTR(L"VERSION"),CComVariant(version) );</P>
<P> IWorkspacePtr openWorkspace;<BR> IWorkspaceFactoryPtr ipWorkspaceFactory;<BR> ipWorkspaceFactory.CreateInstance(CLSID_SdeWorkspaceFactory);<BR> ipWorkspaceFactory ->Open(ipPropertySet,NULL, ;openWorkspace);<BR> if(openWorkspace == 0 ) return S_FALSE;<BR> (*ipSdeWS) = openWorkspace;<BR> (*ipSdeWS) ->AddRef();</P>
<P><BR> return S_OK;</P>
<P>//Connected<BR>}</P>
喜欢0 评分0
gisempire100
捉鬼专家
捉鬼专家
  • 注册日期2004-08-13
  • 发帖数552
  • QQ
  • 铜币2462枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2008-01-10 09:57
$WINDOWS_PATH$\system32\drivers\etc下面的hosts.msn、services有没有主机ip绑定和端口绑定?
A friend is never known till a man has need. ...CL
举报 回复(0) 喜欢(0)     评分
libertine
路人甲
路人甲
  • 注册日期2006-09-22
  • 发帖数14
  • QQ
  • 铜币189枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2008-01-10 10:38
<P>没看过,但是如果需要绑定的 话,Catalog是怎么做到的呢?它每次连服务器之前都要先用ip找到服务器的名字吗?</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部