This sample shows how to open a raster dataset in an ArcSDE geodatabase.
How to use
- Paste the function into your project.
- Call this function from your code.
Public Function OpenArcSDERasterDataset(sServer As String, _
sInstance As String, _
sDatabase As String, _
sUser As String, _
sPassword As String, _
sRasterDatasetName As String, _
Optional sVersion As String = "sde.DEFAULT") As IRasterDataset
' Open an ArcSDE raster dataset with the given name
' sServer, sInstance, sDatabase, sUser, sPassword, sVersion are database connection info
' sRasterDatasetName is the name of the raster dataset
'sFile is the filename
Dim pWsFact As IWorkspaceFactory
Dim pWs As IRasterWorkspaceEx
Dim pRasterDataset As IRasterDataset
Dim pPropertySet As IPropertySet
'Open the ArcSDE workspace
Set pPropertySet = New PropertySet
With pPropertySet
.SetProperty "server", sServer
.SetProperty "instance", sInstance
.SetProperty "database", sDatabase
.SetProperty "user", sUser
.SetProperty "password", sPassword
.SetProperty "version", sVersion
End With
Set pWsFact = New SdeWorkspaceFactory
Set pWs = pWsFact.Open(pPropertySet, 0)
'Open the ArcSDE raster dataset
Set pRasterDataset = pWs.OpenRasterDataset(sRasterDatasetName)
'Return
Set OpenArcSDERasterDataset = pRasterDataset
Set pWsFact = Nothing
Set pWs = Nothing
Set pRasterDataset = Nothing
End Function