ArcGIS Pro SDK C#: How to Create Layer and Add it to Active Map

1545
2
Jump to solution
01-20-2022 08:15 AM
JadedEarth
Occasional Contributor

I'm trying to add a feature class to my Active Map from an SDE geodatabase connection.  My code is as follows inside a button-click event:

string url = @"E:\WorkingFolder\SWATAddIn\GIS_TMP_Connection.sde\MG.dbo.APEX_SWAT_COMP_HUC8";  

Uri uri = new Uri(url);
await QueuedTask.Run(() => LayerFactory.Instance.CreateLayer(uri, MapView.Active.Map));

 

However, it doesn't load and the error says it's unable to add data (doesn't explain why).  If I remove the "MG.dbo." notation before the feature class name, it flags, "Data is not suppported."

What am I doing wrong?

Appreciate any help.

0 Kudos
1 Solution

Accepted Solutions
JadedEarth
Occasional Contributor

Hi y'all,

Found out the problem:  The spatial table I was trying to add didn't have an OBJECTID.  I modified the table to add an IDENTITY(1, 1) integer.  

It's now loading.  Easy to forget such things.

View solution in original post

0 Kudos
2 Replies
JadedEarth
Occasional Contributor

Hi y'all,

Found out the problem:  The spatial table I was trying to add didn't have an OBJECTID.  I modified the table to add an IDENTITY(1, 1) integer.  

It's now loading.  Easy to forget such things.

0 Kudos
FredericPoliart_EsriAU
Occasional Contributor II
Is drive E: a shared drive?
Try using a URL to a layer (ex https://domain.com/ArcGIS/rest/your map server/3/ ), To check if that gets accepted, first.



0 Kudos