The following example creates a new personal geodatabase, then uses IFeatureDataConverter::ConvertFeatureDataset to convert an ArcSDE feature dataset into a feature dataset in the new Access database.
To successfully run this script yourself, you must modify the SDE connection information to match that needed to connect to your server. This script assumes that you have already successfully run the "Converting Shapefile to an ArcSDE Geodatabase" sample.
How to use
- Modify the code to fit your data.
- Paste the code into your VB or VBA Application.
Sub CopyDS()
' +++ Set connection properties. Change the properties to match your
' +++ server name, instance, user name and password for your SDE database
Dim pOutSDEPropset As IPropertySet
Set pOutSDEPropset = New propertySet
With pOutSDEPropset
.SetProperty "Server", "stout"
.SetProperty "Instance", "sde4_ora"
.SetProperty "user", "gdb"
.SetProperty "password", "gdb"
.SetProperty "version", "SDE.DEFAULT"
End With
Dim pInSDEWorkspaceName As IWorkspaceName
Set pInSDEWorkspaceName = New WorkspaceName
pInSDEWorkspaceName.connectionProperties = pOutSDEPropset
pInSDEWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory.1"
' +++ get the name object for the input SDE feature dataset
Dim pFeatureDatasetName As IFeatureDatasetName
Set pFeatureDatasetName = New FeatureDatasetName
Dim pSDEDatasetName As IDatasetName
Set pSDEDatasetName = pFeatureDatasetName
pSDEDatasetName.Name = "USA"
Set pSDEDatasetName.WorkspaceName = pInSDEWorkspaceName
' +++ create a new Access database to copy the feature dataset into
Dim pOutAcFact As IWorkspaceFactory
Set pOutAcFact = New AccessWorkspaceFactory
Dim pOutAcWorkspaceName As IWorkspaceName
Set pOutAcWorkspaceName = pOutAcFact.Create("C:\", "Usa", Nothing, 0)
' +++ create a new feature datset name object for the output Access
' +++ feature dataset, call it "USA"
Dim pOutAcFeatDSName As IFeatureDatasetName
Set pOutAcFeatDSName = New FeatureDatasetName
Dim pOutAcDSName As IDatasetName
Set pOutAcDSName = pOutAcFeatDSName
Set pOutAcDSName.WorkspaceName = pOutAcWorkspaceName
pOutAcDSName.Name = "USA"
' +++ now do the conversion
Dim pFdtoFd As IFeatureDataConverter
Set pFdtoFd = New FeatureDataConverter
pFdtoFd.ConvertFeatureDataset pFeatureDatasetName, pOutAcFeatDSName, Nothing, "", 1000, 0
MsgBox "Conversion complete!"
End Sub