0

I am having a problem in connecting to the database through code in VS 2010 (C#). My colleagues don't have this problem on their machines and can login without any problem.

ArcGIS version 10.2.2, the same as my colleagues. I can connect to the database outside the ArcMap, without any problem.

Also, I didn't find anyone with the same error code as mine "HRESULT 0x8004021A or -2147220966" in the Internet and already tried to search Google page 2 and forward so I'm kind of desperate and running out of ideas.

Here are some prints of the issue: enter image description here enter image description here

The IWorkspaceFactory.Open pops-up the ArcGIS Database Connection, and after I try to connect (which seems to not even trying to connect since its too fast in showing the error message) it just shows that error as you can see in the print. I can't see the IWorkspaceFactory.Open method since its a black boxed API. I already reinstalled the ArcObjectsSDKNet because the problem seems to be in the API.

  • 1
    Which version of ArcGIS are you using and is it the same as your colleagues? – Rich Wawrzonek Sep 2 '16 at 18:08
  • 1
    check the versions. also, if you are connection to oracle, are you sure oracle is properly configured? it's pretty annoying to configure oracle, so check that you can connect to oracle properly, outside of the Arc environment. – George Silva Sep 2 '16 at 18:16
  • @RichWawrzonek Post edited: ArcGIS version 10.2.2, the same as my collegues. I can connect to the database outside the arcmap, without any problem. i think ArcObjects SDK might be the problem – Ricardo Marques Sep 5 '16 at 10:08
  • @George Post edited: ArcGIS version 10.2.2, the same as my collegues. I can connect to the database outside the arcmap, without any problem. i think ArcObjects SDK might be the problem – Ricardo Marques Sep 5 '16 at 10:08
  • Outside of ArcMap can you connect with a 32 bit client? – nef001 Sep 7 '16 at 10:14
1

I'm not certain if this is causing your error but you want to avoid using the 'new' keyword to open workspaces in ArcObjects or you'll eventually have issues. Instead put a method like this in your solution and pass the property set to it:

    ///<summary>Open a sde geodatabase with the input property set.</summary> 
    ///<param name="propertySet">IPropertySet object</param>  
    ///<returns>A workspace name object</returns>  
    public static IWorkspace OpenSdeWorkspaceFromPropertySet(IPropertySet propertySet)
    {
        IWorkspaceFactory2 workspaceFactory2 = null;
        try
        {
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
            workspaceFactory2 = (IWorkspaceFactory2)Activator.CreateInstance(factoryType);
            return workspaceFactory2.Open(propertySet, 0);
        }
        finally
        {
            if (workspaceFactory2 != null) Marshal.ReleaseComObject(workspaceFactory2);
        }
    }

The other things to check are whether your colleagues are using the same version of ArcGIS. I have noticed that with 10.0 I had to set the port number (5151) to the property set instance field. But in 10.2 and higher I set it like this sde:oracle11g:(instance name). But first of all I would make sure you can use this machine to connect to the db outside of ArcGIS.

  • Tried that and still got the same error :/. ArcGIS version 10.2.2, the same as my collegues. I can connect to the database outside the arcmap, without any problem. – Ricardo Marques Sep 5 '16 at 13:48

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.