1

i am having some trouble connecting to Oracle12c via ArcObjects and EZCONNECT.

Results so far:

• Can connect via ArcCatalog 10.2.2 using an *.sde file. (EZCONNECT)

• Can connect via ArcObjects using an *.sde file. (WorkspaceFactory2.OpenFromFile)

• Cannot connect via ArcObjects using a connection property set. (WorkspaceFactory2.Open)

• Cannot connect via ArcObjects using a connection string. (WorkspaceFactory2.OpenFromString)

Can someone offer any pointers?

Supporting info:

• Oracle FAQ on EZCONNECT

http://www.orafaq.com/wiki/EZCONNECT

• ESRI Blog on Easy Connect

http://blogs.esri.com/esri/supportcenter/2012/10/10/easy-connect-connecting-to-arcsde-just-got-easier/

EDIT - No errors are thrown, this .NET add-in just shuts down ArcMap with no warning or error. Not having luck debugging in VS2012 either.

UPDATE - Well, I think we got it mostly resolved; a misuse of connection properties. The code snippets below should shed the light.

So can now programmatically pass all of the db connection properties necessary, including the Easy Connect string.

HOWEVER, I still have an issue where the Database Connection dialog appears and must be manually “OK’d” to initiate connection.

The Database Connection dialog was not appearing previously when using the “traditional” connection properties to connect to Oracle11g.

So if you have any thoughts, I am all ears.

/// CODE SNIPPET BEFORE
/// Using "traditional" connection properties. 
/// Create an SDE connection property set and populate it with connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("SERVER", "server");
propertySet.SetProperty("INSTANCE", "instance"); //this is where i was trying to pass the Oracle Easy Connect string 
propertySet.SetProperty("DATABASE", "");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "pass");
propertySet.SetProperty("VERSION", "sde.DEFAULT");
/// Open the geodatabase using the property set. 
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);

/// CODE SNIPPET AFTER
/// Using Oracle “Easy Connect” connection string. 
/// Create a DB connection property set and populate it with connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("DATABASE_CONNECTION_PROPERTIES", "user/pass@server:port/service"); //this is the Oracle Easy Connect string 
//propertySet.SetProperty("DBCLIENT", "oracle");
//propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "pass");
/// Open the database using the property set. 
IWorkspace workspace = workspaceFactory.Open(propertySet, 0);
  • Please edit the question to include the exact error you are receiving. – Vince May 5 '15 at 13:47
4

Not sure why the question got "voted down". Thanks for the constructive input. Anywho, for those that understood the question, or are facing a similar challenge, here is/are the solution/s that was/were reached, tested, and proven to work.

Summary

  • It was the connection property parameter names.

  • DB_CONNECTION_PROPERTIES vs. DATABASE_CONNECTION_PROPERTIES

  • While some of the geodatabase examples use “DB_CONNECTION_PROPERTIES”, the help documentation/description uses “DATABASE_CONNECTION_PROPERTIES”.

  • In similar scenarios, use DB_CONNECTION_PROPERTIES, not DATABASE_CONNECTION_PROPERTIES.

    //TARGET SOLUTION
    
    // Using Oracle “Easy Connect” connection string.
    
    // Create a DB connection string with connection properties.
    
    string connString = "DB_CONNECTION_PROPERTIES=server:port/service;DBCLIENT=oracle;USER=user;password=pass";
    
    // Open the database using the connection string.
    
    IWorkspace workspace = workspaceFactory.OpenFromString(connString, 0);
    

    //ALTERNATIVE SOLUTION 1

    // Using Oracle “Easy Connect” connection properties.

    // Create a DB connection property set and populate it with connection properties.

    IPropertySet propertySet = new PropertySetClass();

    propertySet.SetProperty("DB_CONNECTION_PROPERTIES", "user/pass@server:port/service");

    propertySet.SetProperty("DBCLIENT", "oracle");

    propertySet.SetProperty("USER", "user");

    propertySet.SetProperty("PASSWORD", "pass");

    // Open the database using the property set.

    IWorkspace workspace = workspaceFactory.Open(propertySet, 0);

    //ALTERNATIVE SOLUTION 2

    // Using “traditional” connection properties.

    // Create a property set and populate it with connection properties.

    IPropertySet propertySet = new PropertySet();

    propertySet.SetProperty("SERVER", “server”);

    propertySet.SetProperty("INSTANCE", "sde:oracle$server:port/service");

    propertySet.SetProperty("DATABASE", "");

    propertySet.SetProperty("USER", "user");

    propertySet.SetProperty("PASSWORD", "pass");

    // Open the database using the property set.

    IWorkspace workspace = workspaceFactory.Open(propertySet, 0); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.