The following code is to open the Default version of a database and create a new version to perform edits with.
Dim pPropset As esriSystem.IPropertySet
Set pPropset = New esriSystem.PropertySet
Dim pFact As esriGeoDatabase.IWorkspaceFactory
Dim pWorkspace As IWorkspace
Dim gFeatureWorkspace As IFeatureWorkspace
With pPropset
.SetProperty "Provider", "Esri.GeoDB.OLEDB.1"
.SetProperty "Server", "Server9"
.SetProperty "Instance", "sde:sqlserver:Server9"
'.SetProperty "Database", "DBName"
.SetProperty "User", "User"
.SetProperty "Password", "UserPW"
.SetProperty "version", "sde.DEFAULT"
End With
Set pFact = New esriDataSourcesGDB.SdeWorkspaceFactory
Set pWorkspace = pFact.Open(pPropset, 0)
'Set gFeatureWorkspace = pWorkspace
Dim pVerWS As IVersionedWorkspace
Set pVerWS = pWorkspace
Dim pVersion As IVersion
Set pVersion = pVerWS.DefaultVersion
pVersion.CreateVersion ("MassLoad")
At the Set pVersion = pVerWS.DefaultVersion a type mismatch error 13 is returned.