Select to view content in your preferred language

add sqlserver table into arcgispro and enable editing layer

177
1
07-28-2024 11:46 PM
shadiOmrani
New Contributor

hi everyone

I want to add sqlserverExpress Table into arcgispro layout with sdk.net . for this purpose i use below code but when  i start editing my feature layer ,it says "this workspace is not editable"

what is my code problem?

DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
{
AuthenticationMode = AuthenticationMode.OSA,
Instance = @"localhost\sqlexpress",
Database = "db_" + LoginUserControl.userId.Replace("-", "_"),
Version = "dbo.DEFAULT"

};

await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Geodatabase geodatabase = new Geodatabase(connectionProperties);
Map map = MapView.Active.Map;
CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
{
WorkspaceConnectionString = geodatabase.GetConnectionString(),
GeometryType = GetGeomType(StrGeomType),
OIDFields = "Nid",
Srid = "4326",
SqlQuery = String.Format("select * from [db_{0}].[dbo].[layer_{1}]", LoginUserControl.userId.Replace("-", "_"), layerId),
Dataset = "test",
DatasetType=esriDatasetType.esriDTFeatureClass


};
var lcp = new LayerCreationParams(sqldc){ Name = layerName, };
FeatureLayer flyr = LayerFactory.Instance.CreateLayer<FeatureLayer>(lcp, map);

 

thanks

0 Kudos
1 Reply
Aashis
by Esri Contributor
Esri Contributor

In the code, you are creating a query layer that is read-only when accessed directly from a database connection.

According to the doc, to edit database tables accessed as a query layer, share them as a web feature layer, and access them from your portal. The query layer cannot contain virtual columns, where clauses, or joins. In addition, query layers that access data in a cloud data warehouse are not editable even through a web feature layer.