阅读:1934回复:1
创建一个SDEWorkSpace
<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> |
|
1楼#
发布于:2004-08-11 08:45
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
|