Appending an Itable to IFeatureClass

555
2
Jump to solution
06-10-2023 09:20 AM
MeleKoneya
Occasional Contributor III

I have a table stored in a SQL (non GDB) database.   The  table has SQL geometry.

I need to append this table to a featureclass in a SQL Geodatabase.

I am able to Access an ITable from the SQL DB, but not an IFeatureClass.

When I try to append the ITable to an IFeature Class using the AppendFeatures in C#,  I get an error that says the input and output must be of the same type.

How do I get my ITable cast to and IFeatureclass?

Thanks,

Mele    

0 Kudos
1 Solution

Accepted Solutions
MeleKoneya
Occasional Contributor III

Duncan,    Thank you for the reply.    By append,  I meant adding rows to the feature class.   I was able to find a .NET ArcObjects way to do this.   Sorry I did not post it but what I did was to get a feature class from the DBMS database and use that to append to an SDE feature class 

private static IFeatureClass CreateSQLFC(string SQLSERVER, string UID, string PWD, string DB, string fc)
{
IPropertySet propSet = new PropertySetClass();
propSet.SetProperty("DBCLIENT", "SQLServer");
propSet.SetProperty("serverinstance", SQLSERVER);
propSet.SetProperty("authentication_mode", "DBMS");
propSet.SetProperty("user", UID);
propSet.SetProperty("password", PWD);
propSet.SetProperty("DATABASE", DB);

IWorkspaceFactory2 pWSFact = (IWorkspaceFactory2)new SqlWorkspaceFactory();

IWorkspace WS = pWSFact.Open(propSet, 0);
IFeatureWorkspace FWS = (IFeatureWorkspace)WS;

IFeatureClass pFC = (IFeatureClass)FWS.OpenFeatureClass(fc);

return pFC;


}

View solution in original post

0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor

When you say "Append" do you mean join fields from the table to the Feature class or do you mean insert rows from the table to the end of the Feature class?  I've never used a table with "SQL geometry" so my gut feeling is if you are trying to insert rows then there might be a compatibility issue. You need to clarify what you mean by append as that can be read two ways?

0 Kudos
MeleKoneya
Occasional Contributor III

Duncan,    Thank you for the reply.    By append,  I meant adding rows to the feature class.   I was able to find a .NET ArcObjects way to do this.   Sorry I did not post it but what I did was to get a feature class from the DBMS database and use that to append to an SDE feature class 

private static IFeatureClass CreateSQLFC(string SQLSERVER, string UID, string PWD, string DB, string fc)
{
IPropertySet propSet = new PropertySetClass();
propSet.SetProperty("DBCLIENT", "SQLServer");
propSet.SetProperty("serverinstance", SQLSERVER);
propSet.SetProperty("authentication_mode", "DBMS");
propSet.SetProperty("user", UID);
propSet.SetProperty("password", PWD);
propSet.SetProperty("DATABASE", DB);

IWorkspaceFactory2 pWSFact = (IWorkspaceFactory2)new SqlWorkspaceFactory();

IWorkspace WS = pWSFact.Open(propSet, 0);
IFeatureWorkspace FWS = (IFeatureWorkspace)WS;

IFeatureClass pFC = (IFeatureClass)FWS.OpenFeatureClass(fc);

return pFC;


}

0 Kudos