阅读:1153回复:0
sde栅格数据问题
<P>请问高手,当我用如下代码打开影像数据时,为何<FONT color=#000080>Set</FONT> pSDERasterDataset = pName.Open得不到栅格数据集?
</P><PRE><CODE><FONT color=#000080>Public Function</FONT></CODE> GetRasterFromSDE(sServer <CODE><FONT color=#000080>As String</FONT></CODE>, sInstance <CODE><FONT color=#000080>As String</FONT></CODE>, _ sDB <CODE><FONT color=#000080>As String</FONT></CODE>, sUser <CODE><FONT color=#000080>As String</FONT></CODE>, sPassword <CODE><FONT color=#000080>As String</FONT></CODE>, sSDERaster <CODE><FONT color=#000080>As String</FONT></CODE>) <CODE><FONT color=#000080>As</FONT></CODE> IRasterDataset <CODE><FONT color=#008000>' sServer,sInstance,sDB,sUser,sPasswd: ArcSDE connection info</FONT></CODE> <CODE><FONT color=#008000>' sSDERaster: the ArcSDE raster dataset name </FONT></CODE> <CODE><FONT color=#000080>Dim</FONT></CODE> pSDEWs <CODE><FONT color=#000080>As</FONT></CODE> IWorkspaceName <CODE><FONT color=#000080>Dim</FONT></CODE> pSDEPropertySet <CODE><FONT color=#000080>As</FONT></CODE> IPropertySet <CODE><FONT color=#000080>Dim</FONT></CODE> pSDERasterDataset as IRasterDataset <CODE><FONT color=#000080>Dim</FONT></CODE> pDsName <CODE><FONT color=#000080>As</FONT></CODE> IDatasetName <CODE><FONT color=#000080>Dim</FONT></CODE> pName <CODE><FONT color=#000080>As</FONT></CODE> IName <CODE><FONT color=#000080>Dim</FONT></CODE> sQualifiedName <CODE><FONT color=#000080>As String</FONT></CODE> <CODE><FONT color=#008000>' Get connection propertyset</FONT></CODE> <CODE><FONT color=#000080>Set</FONT></CODE> pSDEPropertySet = <CODE><FONT color=#000080>New</FONT></CODE> PropertySet <CODE><FONT color=#000080>With</FONT></CODE> pSDEPropertySet .SetProperty "Server", sServer .SetProperty "Instance", sInstance .SetProperty "Database", sDB .SetProperty "User", sUser .SetProperty "Password", sPassword .SetProperty "Version", "SDE.DEFAULT" <CODE><FONT color=#000080>End With</FONT></CODE> <CODE><FONT color=#008000>' Get workspacename</FONT></CODE> <CODE><FONT color=#000080>Set</FONT></CODE> pSDEWs = <CODE><FONT color=#000080>New</FONT></CODE> WorkspaceName pSDEWs.ConnectionProperties = pSDEPropertySet pSDEWs.WorkspaceFactoryProgID = "esricore.sdeworkspacefactory" <CODE><FONT color=#008000>' Get qualified ArcSDE raster name</FONT></CODE> if len(sDB) > 0 <CODE><FONT color=#000080>Then</FONT></CODE> sQualifiedName = sDB + "." + sUser + "." + sSDERaster <CODE><FONT color=#000080>Else</FONT></CODE> sQualifiedName = sUser + "." + sSDERaster <CODE><FONT color=#000080>End If</FONT></CODE> <CODE><FONT color=#008000>' Get raster dataset name</FONT></CODE> <CODE><FONT color=#000080>Set</FONT></CODE> pDsName = <CODE><FONT color=#000080>New</FONT></CODE> RasterDatasetName pDsName.Name = sQualifiedName <CODE><FONT color=#000080>Set</FONT></CODE> pDsName.WorkspaceName = pSDEWs <CODE><FONT color=#000080>Set</FONT></CODE> pName = pDsName <CODE><FONT color=#008000>' Open ArcSDE raster dataset</FONT></CODE> <CODE><FONT color=#000080>Set</FONT></CODE> pSDERasterDataset = pName.Open <CODE><FONT color=#008000>' Cleanup</FONT></CODE> <CODE><FONT color=#000080>Set</FONT></CODE> GetRasterFromSDE = pSDERasterDataset <CODE><FONT color=#000080>Set</FONT></CODE> pSDEWs = <CODE><FONT color=#000080>Nothing Set</FONT></CODE> pSDERasterDataset = <CODE><FONT color=#000080>Nothing Set</FONT></CODE> pSDEPropertyset = <CODE><FONT color=#000080>Nothing Set</FONT></CODE> pName = <CODE><FONT color=#000080>Nothing Set</FONT></CODE> pDsName = <CODE><FONT color=#000080>Nothing End Function</FONT></CODE> </PRE> |
|