Unable to instantiate Database using SQLServer SDE connection

242
1
Jump to solution
01-07-2021 06:11 AM
DavidLaMartina
New Contributor III

I'm trying to read in the connection properties from the DataConnection property of a CIMFeatureLayer's FeatureTable property, and use those properties to instantiate an ArcGIS.Core.Data.Database object (using the constructor that takes a DatabaseConnectionProperties object). This is a SQLServer connection that was created in the Catalog, and whose layer(s) were added to the Map represented in a CIMMapDocument.

I have done this successfully with an Oracle connection, but I'm having trouble getting it to work with a SQLServer connection. I am just parsing the WorkspaceConnectionString from the CIMStandardDataConnection and using those key-value pairs (AuthenticationMode, Branch, Database, Instance, etc.) to create a DatabaseConnectionProperties object.

The issue with a SQLServer connection happens when I try to instantiate a Database object using those properties. The constructor call causes the database configuration dialog to pop up in the the Arc Pro GUI - which is expected, given that the password is not saved unencrypted in the CIM, and it will need to be provided. However, when I enter the password, I get an indefinite hang. If I turn on the most granular exception-handling in my debugger, I get the COM exception: 'Exception from HRESULT: 0x80050199'. Following that exception is the GeodatabaseEnterpriseException, : 'Lost connection to underlying DBMS. Reason: Failure to access the DBMS server'.

I'm not sure how to proceed. There could be something wrong in the way I'm creating the DatabaseConnectionProperties, but the fact that the same method is working for an Oracle connection makes me wonder if the problem lies elsewhere.

1 Solution

Accepted Solutions
DavidLaMartina
New Contributor III

I figured this out. If anyone else is having a similar problem, my issue was that I was taking the "INSTANCE" key-value pair out of the workspace connection string and assigning it to the Instance property of the DatabaseConnectionProperties object used to instantiate the Database. The value in this case was something along the lines of 

sde:sqlserver:server\instance

This didn't cause any problems for Oracle connections (sde:oracle:instance), but for SQL Server it was apparently not even connecting to an existing instance. I instead used the DB_CONNECTION_PROPERTIES value from the workspace connection string - but still assigned that value to the Instance property of the DatabaseConnectionProperties object. The only difference in the values is that the DB_CONNECTION_PROPERTIES value is simply server\instance (no sde:sqlserver qualifier).

View solution in original post

0 Kudos
1 Reply
DavidLaMartina
New Contributor III

I figured this out. If anyone else is having a similar problem, my issue was that I was taking the "INSTANCE" key-value pair out of the workspace connection string and assigning it to the Instance property of the DatabaseConnectionProperties object used to instantiate the Database. The value in this case was something along the lines of 

sde:sqlserver:server\instance

This didn't cause any problems for Oracle connections (sde:oracle:instance), but for SQL Server it was apparently not even connecting to an existing instance. I instead used the DB_CONNECTION_PROPERTIES value from the workspace connection string - but still assigned that value to the Instance property of the DatabaseConnectionProperties object. The only difference in the values is that the DB_CONNECTION_PROPERTIES value is simply server\instance (no sde:sqlserver qualifier).

View solution in original post

0 Kudos