[GIS] Connecting to Oracle User Schema Geodatabase using ArcObjects

arcgis-10.3arcobjectsoracle-spatial

I've set up an Oracle user Schema geodatabase and loaded some data into it. I now want to connect to it programmatically using ArcObjects, the problem is I don't see how. Where can I set the newly created schema name in my connection property set, or how do I change the schema value after I have connected? In ArcCatalog it is done in the Geodatabase connection properties window :
enter image description here

The code below works fine connecting to the default SDE schema. What do I have to change to connect to a user geodatabase? I have tried examining IDatabaseConnectionInfo2 and IWorkspaceProperties but I don't see where I can set or change the schema that is connected to.

 public static IWorkspace ConnectToTransactionalVersion(String dbclient, String dbConnProp, String user, String password, String database, String version, String authentication)
    {
        IPropertySet propertySet = new PropertySet();
        propertySet.SetProperty("DBCLIENT", dbclient);
        propertySet.SetProperty("DB_CONNECTION_PROPERTIES", dbConnProp);
        propertySet.SetProperty("DATABASE", database);
        propertySet.SetProperty("USER", user);
        propertySet.SetProperty("PASSWORD", password);
        propertySet.SetProperty("VERSION", version);
        propertySet.SetProperty("AUTHENTICATION_MODE", authentication);
        Type factoryType = Type.GetTypeFromProgID(
            "esriDataSourcesGDB.SdeWorkspaceFactory");
        IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance
            (factoryType);
        return workspaceFactory.Open(propertySet, 0);
    }

I tried adding "SCHEMA" as a property in propertySet and it gets ignored, I also tried setting the version property to the new user schema default version but it errors with "version not found"

Best Answer

Create a connection file (sde file) with ArcCatalog.

Solution 1: Use this connection file like in my example (first 7 lines). I think this is not that good, because you have to distribute the sde file, too.

Solution 2: Maybe you can make some kind of ‘reverse engeneering’. In the example below (all lines) you could establish the connection to your workspace by the sde file and read the properties of this file. I hope you will find the missing parameter.

IWorkspaceFactory wsFactory = null;
IFeatureWorkspace featWs = null;
object names = null;
object values = null;
try
{
    wsFactory = new SdeWorkspaceFactoryClass();
    featWs = (IFeatureWorkspace)wsFactory.OpenFromFile(@"D:\Test.sde", 0);

    IWorkspace ws = featWs as IWorkspace;
    if (ws != null)
    {
        IPropertySet props = ws.ConnectionProperties;
        props.GetAllProperties(out names, out values);
    }
}
catch (Exception ex)
{
}