<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SQL Server backed FeatureLayer added to the map has display issues in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1325576#M10322</link>
    <description>&lt;P&gt;Thanks, I indeed managed to add the item to the Catalog. However, it gets more complicated.&lt;/P&gt;&lt;P&gt;The item that can be added to the Catalog has to exist on disk (ItemType = PathItem). For that we need to create a connection file and save it to the disk. There is no .NET interface to build the connection file so the creation of the connection has to go via Python: via&amp;nbsp;Geoprocessing.ExecuteToolAsync("management.CreateDatabaseConnection", @params)&amp;nbsp;&lt;/P&gt;&lt;P&gt;... and that brings us to yet another problem that I describe here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/management-createdatabaseconnection-takes-2/m-p/1325382#M10311" target="_blank"&gt;https://community.esri.com/t5/arcgis-pro-sdk-questions/management-createdatabaseconnection-takes-2/m-p/1325382#M10311&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those interested in the code&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal static object[] GetSdeFileParams()
{
	var out_folder_path = Project.Current.HomeFolderPath;
	var out_name = SDEConnectionName;
	var database_platform = "SQL_SERVER";
	var instance = "XXX";
	var account_authentication = "DATABASE_AUTH";
	var username = "USERID";
	var password = "YYY";
	var save_user_pass = "SAVE_USERNAME";
	var database = "ZZZ";

	return new object[]
			{
				out_folder_path,
				out_name,
				database_platform,
				instance,
				account_authentication,
				username,
				password,
				save_user_pass,
				database
			};
}

var p = GetSdeFileParams();
var va = Geoprocessing.MakeValueArray(p);
IGPResult result = await Geoprocessing.ExecuteToolAsync("management.CreateDatabaseConnection", va);

await QueuedTask.Run(() =&amp;gt;
{         
	var sdeFilePath = System.IO.Path.Combine(Project.Current.HomeFolderPath, SDEConnectionName);
	var item = ItemFactory.Instance.Create(sdeFilePath);
	var gdbitem = item as GDBProjectItem;
	Project.Current.AddItem(gdbitem);
});&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 05 Sep 2023 19:05:10 GMT</pubDate>
    <dc:creator>ViktorSafar</dc:creator>
    <dc:date>2023-09-05T19:05:10Z</dc:date>
    <item>
      <title>SQL Server backed FeatureLayer added to the map has display issues</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1321030#M10224</link>
      <description>&lt;P&gt;I am adding a FeatureLayer to the current map. The FL is backed by table in a SQL Server database. This is how I add the FL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var connProps = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
{
	Instance = "my remote instance",
	Database = "dbname",
	User = "****",
	Password = "****",
	AuthenticationMode = AuthenticationMode.DBMS,
};

var gdb = new Geodatabase(connProps);

CIMSqlQueryDataConnection connection = new CIMSqlQueryDataConnection()
{
	WorkspaceConnectionString = gdb.GetConnectionString(),
	GeometryType = esriGeometryType.esriGeometryPolygon,
	OIDFields = "OBJECTID",
	Srid = "32632",
	SqlQuery = "select * from [dbname].[fb_gdb].[TRAININGAREA]",
	Dataset = "TrainingAreas",
	DatasetType = esriDatasetType.esriDTFeatureClass
};

var layerParams = new LayerCreationParams(connection )
{
	Name = Constants.LayerTrainingAreasName
};

var layer = LayerFactory.Instance.CreateLayer&amp;lt;FeatureLayer&amp;gt;(layerParams, MapView.Active.Map);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The layer contains polygons and I added a renderer with a pink outline. During panning/zooming the features are not drawn well - sometimes completely missing, sometimes a chunk of the outline is missing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ViktorSafar_0-1692693498887.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/78747i34FC239CC3B5A9E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ViktorSafar_0-1692693498887.png" alt="ViktorSafar_0-1692693498887.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I add the same layer via Pro's&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class=""&gt;Catalog -&amp;gt; Databases -&amp;gt; Add connection, and then drag and drop the layer into the map, it behaves correctly.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Any ideas?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have tried to add the connection to the Catalog via code to see if that helps but was unable to figure out how to do that&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Project.Current.AddItem( how do I make an IProjectItem out of the GDB or the connection?? )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 08:43:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1321030#M10224</guid>
      <dc:creator>ViktorSafar</dc:creator>
      <dc:date>2023-08-22T08:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Server backed FeatureLayer added to the map has display issues</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1321100#M10226</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This link might help you&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/3.0/sdk/api-reference/topic8955.html" target="_self"&gt;https://pro.arcgis.com/en/pro-app/3.0/sdk/api-reference/topic8955.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 12:28:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1321100#M10226</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-08-22T12:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Server backed FeatureLayer added to the map has display issues</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1325576#M10322</link>
      <description>&lt;P&gt;Thanks, I indeed managed to add the item to the Catalog. However, it gets more complicated.&lt;/P&gt;&lt;P&gt;The item that can be added to the Catalog has to exist on disk (ItemType = PathItem). For that we need to create a connection file and save it to the disk. There is no .NET interface to build the connection file so the creation of the connection has to go via Python: via&amp;nbsp;Geoprocessing.ExecuteToolAsync("management.CreateDatabaseConnection", @params)&amp;nbsp;&lt;/P&gt;&lt;P&gt;... and that brings us to yet another problem that I describe here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/management-createdatabaseconnection-takes-2/m-p/1325382#M10311" target="_blank"&gt;https://community.esri.com/t5/arcgis-pro-sdk-questions/management-createdatabaseconnection-takes-2/m-p/1325382#M10311&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For those interested in the code&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal static object[] GetSdeFileParams()
{
	var out_folder_path = Project.Current.HomeFolderPath;
	var out_name = SDEConnectionName;
	var database_platform = "SQL_SERVER";
	var instance = "XXX";
	var account_authentication = "DATABASE_AUTH";
	var username = "USERID";
	var password = "YYY";
	var save_user_pass = "SAVE_USERNAME";
	var database = "ZZZ";

	return new object[]
			{
				out_folder_path,
				out_name,
				database_platform,
				instance,
				account_authentication,
				username,
				password,
				save_user_pass,
				database
			};
}

var p = GetSdeFileParams();
var va = Geoprocessing.MakeValueArray(p);
IGPResult result = await Geoprocessing.ExecuteToolAsync("management.CreateDatabaseConnection", va);

await QueuedTask.Run(() =&amp;gt;
{         
	var sdeFilePath = System.IO.Path.Combine(Project.Current.HomeFolderPath, SDEConnectionName);
	var item = ItemFactory.Instance.Create(sdeFilePath);
	var gdbitem = item as GDBProjectItem;
	Project.Current.AddItem(gdbitem);
});&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Sep 2023 19:05:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/sql-server-backed-featurelayer-added-to-the-map/m-p/1325576#M10322</guid>
      <dc:creator>ViktorSafar</dc:creator>
      <dc:date>2023-09-05T19:05:10Z</dc:date>
    </item>
  </channel>
</rss>

