gsl1982
路人甲
路人甲
  • 注册日期2004-05-08
  • 发帖数135
  • QQ
  • 铜币543枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1768回复:1

创建一个SDEWorkSpace

楼主#
更多 发布于:2004-08-10 13:25
<P>根据用户输入的口令、密码等SDE服务连接信息,创建出一个SDEWorkSpace对象。</P>
<P ><FONT face="Times New Roman">Sub CreateSDEWorkSpace()</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>定义一个<FONT face="Times New Roman">WorkSpaceFactory</FONT>类工厂</P>
<P ><FONT face="Times New Roman">    Dim pSdeWorkspaceFactory As IWorkspaceFactory</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>定义一个<FONT face="Times New Roman">WorkSpace</FONT>对象</P>
<P ><FONT face="Times New Roman">    Dim pSdeWorkspace As IWorkspace</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>定义一个<FONT face="Times New Roman">PropertySet</FONT>对象<FONT face="Times New Roman">,</FONT>用来设置<FONT face="Times New Roman">SDE</FONT>连接信息<FONT face="Times New Roman">.</FONT></P>
<P ><FONT face="Times New Roman">    Dim pConnectionProperties As IPropertySet</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>创建一个新的<FONT face="Times New Roman">PropertySet</FONT>对象</P>
<P ><FONT face="Times New Roman">    Set pConnectionProperties = New PropertySet</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>设置<FONT face="Times New Roman">SDE</FONT>连接信息</P>
<P ><FONT face="Times New Roman">    With pConnectionProperties</FONT></P>
<P ><FONT face="Times New Roman">           '</FONT>设置服务器名</P>
<P ><FONT face="Times New Roman">        .SetProperty "SERVER", "afei"</FONT></P>
<P ><FONT face="Times New Roman">               '</FONT>设置<FONT face="Times New Roman">ArcSDE</FONT>实例名,也可以是端口号</P>
<P ><FONT face="Times New Roman">        .SetProperty "INSTANCE", "5151/tcp"</FONT></P>
<P ><FONT face="Times New Roman">               '</FONT>设置数据库名</P>
<P ><FONT face="Times New Roman">        .SetProperty "DATABASE", "sde"</FONT></P>
<P ><FONT face="Times New Roman">        '</FONT>设置<FONT face="Times New Roman">SDE</FONT>用户</P>
<P ><FONT face="Times New Roman">        .SetProperty "USER", "sde"</FONT></P>
<P ><FONT face="Times New Roman">               '</FONT>设置<FONT face="Times New Roman">SDE</FONT>用户口令</P>
<P ><FONT face="Times New Roman">        .SetProperty "PASSWORD", "sde"</FONT></P>
<P ><FONT face="Times New Roman">               '</FONT>设置版本参数</P>
<P ><FONT face="Times New Roman">        .SetProperty "VERSION", "SDE.DEFAULT"</FONT></P>
<P ><FONT face="Times New Roman">    End With</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>定义一个<FONT face="Times New Roman">SDE</FONT>类型的<FONT face="Times New Roman">WorkSpace</FONT>类工厂</P>
<P ><FONT face="Times New Roman">    Set pSdeWorkspaceFactory = New SdeWorkspaceFactory</FONT></P>
<P ><FONT face="Times New Roman">    '</FONT>通过类工厂的<FONT face="Times New Roman">Create</FONT>方法返回一个<FONT face="Times New Roman">Sde</FONT>类型的<FONT face="Times New Roman">WorkSpace</FONT>对象<FONT face="Times New Roman">.</FONT></P>
<P ><FONT face="Times New Roman">    Set pSdeWorkspace = pSdeWorkspaceFactory.Open(pConnectionProperties, 0)</FONT></P>
<P ><FONT face="Times New Roman">    If Not pSdeWorkspace Is Nothing Then</FONT></P>
<P ><FONT face="Times New Roman">        MsgBox "</FONT>连接成功<FONT face="Times New Roman">"</FONT></P>
<P ><FONT face="Times New Roman">    Else</FONT></P>
<P ><FONT face="Times New Roman">        MsgBox "</FONT>连接错误<FONT face="Times New Roman">"</FONT></P>
<P ><FONT face="Times New Roman">    End If</FONT></P>
<P>End Sub</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15946
  • QQ554730525
  • 铜币25338枚
  • 威望15363点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2004-08-11 08:45
<img src="images/post/smile/dvbbs/em01.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部