<?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: Define a query for joining data in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451837#M12281</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For some reason I get the &lt;STRONG&gt;SEHException&lt;/STRONG&gt; -2147467259, no matter if &lt;SPAN style="font-style:italic;"&gt;CopyLocally&lt;/SPAN&gt; is set to true or false so its no issue on right-access. &lt;BR /&gt;Do I have to consider a special syntax for the whereClause on an SDE which may differ from &lt;SPAN style="font-style:italic;"&gt;Table.Field&lt;/SPAN&gt;?&lt;BR /&gt;&lt;BR /&gt;Currently this is the code:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
/// &amp;lt;summary&amp;gt;
/// Virtually joins two tables
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="objectTable"&amp;gt;the businesTable&amp;lt;/param&amp;gt;
/// &amp;lt;param name="geometryTable"&amp;gt;the geometry-table where the shapes are stored&amp;lt;/param&amp;gt;
/// &amp;lt;param name="whereString"&amp;gt;an additional whereString to further specify the query&amp;lt;/param&amp;gt;
/// &amp;lt;param name="uuidField"&amp;gt;the identifier-field within the geometry-table (usually OFID) used for joining the tables&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;a FeatureClass that contains the the Objektart, the Modellart and the geometries of the joined tables&amp;lt;/returns&amp;gt;
/// &amp;lt;remarks&amp;gt;
/// The join is performed by evaluating the UUID-field of the object-table and the UUID-field of the geometry-table 
/// (while the former is already "UUID" the latter may vary).&amp;lt;br&amp;gt; /&amp;gt;
/// The returned featureClass contains the fields Modellart (MAT) and Objektart (OBA) from the objectTable and all fields of the geometry-table. 
/// &amp;lt;/remarks&amp;gt;
 
private IFeatureClass joinTables(string objectTable, string geometryTable, string whereString, string uuidField)
{
 // queryDef to perform a join on the object- and the geometry-table
 IQueryDef queryDef = ((IFeatureWorkspace)this.Workspace).CreateQueryDef();
 // select the Objektart (OBA), the Modellart (MAT) and all columns from the geometry-table (where the ESRI-feature is stored)
 queryDef.SubFields = objectTable + ".OBA," + objectTable + ".MAT," + geometryTable + ".*";
 queryDef.Tables = objectTable + "," + geometryTable;
 queryDef.WhereClause = objectTable + ".UUID = " + geometryTable + "." + uuidField; // the join-criterion

 IQueryName2 queryName2 = (IQueryName2)new FeatureQueryNameClass();
 queryName2.QueryDef = queryDef;
 //queryName2.PrimaryKey = geometryTable + "." + uuidField; // the ID-field of the FeatureClass
 //queryName2.CopyLocally = true;

 // Set the workspace and name of the new QueryTable.
 IDatasetName datasetName = (IDatasetName)queryName2;
 datasetName.WorkspaceName = (IWorkspaceName)(((IDataset)this.Workspace).FullName);
 datasetName.Name = "tmpTable";

 // Open the virtual table.
 ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)queryName2;
 return (IFeatureClass)name.Open();
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; I tested this sample using SDE workspace and also GDB workspace and it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I used ArcObjects 10.1 +VS 2010 on windows 7 64-bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Similar exception found here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/22016-ArcMap-C-Integration-sometimes-gives-SEHException" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/22016-ArcMap-C-Integration-sometimes-gives-SEHException&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:09:52 GMT</pubDate>
    <dc:creator>AhmedEl-Sisi</dc:creator>
    <dc:date>2021-12-11T20:09:52Z</dc:date>
    <item>
      <title>Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451829#M12273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey around,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I´m trying to build a query that provides access to features within a FC that intersect a given geometry AND that apply to an attribute-based query from another table by a join. For the last one I may use the &lt;/SPAN&gt;&lt;STRONG&gt;IQueryDef&lt;/STRONG&gt;&lt;SPAN&gt;-interface as it allows joining data based on an attribute-based query, but I need both - a spatial and a attribute-component. Is there any better way then creating one of the filters first, looping the results and checking every feature for the second condition? Maybe by building a temporary table using &lt;/SPAN&gt;&lt;STRONG&gt;IQueryTable&lt;/STRONG&gt;&lt;SPAN&gt; from the QueryDef-object and than perform a spatial query on it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 10:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451829#M12273</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2014-06-25T10:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451830#M12274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Carsten,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ISpatialFilter_Interface/00250000083n000000/"&gt;ISpatialFilter&lt;/A&gt;&lt;SPAN&gt; allows you to specify a spatial query AND an attribute query through the WhereClause.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have joined your tables you should be able to take advantage of this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 13:29:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451830#M12274</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-06-25T13:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451831#M12275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your replies,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you have joined your tables [...]?&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;The question is on how to do this on a query in a non-persistent way. That was why I suggested using &lt;/SPAN&gt;&lt;STRONG&gt;IQueryDef&lt;/STRONG&gt;&lt;SPAN&gt; in combination with &lt;/SPAN&gt;&lt;STRONG&gt;TableQueryName&lt;/STRONG&gt;&lt;SPAN&gt; to build a virtual (joined) table and afterwards query that table spatially. Is this the way or is there another one to achieve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Btw.: Although it won´t matter that much, I´m writing with C# .NET 3.5&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 14:04:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451831#M12275</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2014-06-25T14:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451832#M12276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Carsten,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you can't apply spatial filter on IQueryDef so your approach to use &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/d/002500000n52000000.htm"&gt;TableQueryNameClass &lt;/A&gt;&lt;SPAN&gt;is a good idea if your tables are in the same geodatabase, use it with query definition and then use a spatial filter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/000100000146000000.htm"&gt;http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/000100000146000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jun 2014 18:29:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451832#M12276</guid>
      <dc:creator>AhmedEl-Sisi</dc:creator>
      <dc:date>2014-06-25T18:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451833#M12277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your further replies,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Why not just perform a spatial query and then an attribute query to further refine your search results. I guess I'm not reading it right or just misunderstanding what you are trying to do?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;No, you understand correctly. Honestly this was my first approach and it works, but I looked for a faster way because looping every feature and checking it for the second condition (be it spatial or not) does not seem convenient to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It can be helpful to some posters, to know what language they are using so that others can provide samples that match.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Btw.: Although it won´t matter that much, I´m writing with C# .NET 3.5&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@CC4Ever: I have only one further issue on using the &lt;/SPAN&gt;&lt;STRONG&gt;TableQueryNameClass&lt;/STRONG&gt;&lt;SPAN&gt; on my SDE. I do not understand exactly what the copyLocally-&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;param&lt;/SPAN&gt;&lt;SPAN&gt; is for, I suppose I do not have write-access for the destination-machine (I get a really "meaningful" &lt;/SPAN&gt;&lt;STRONG&gt;SEHException&lt;/STRONG&gt;&lt;SPAN&gt; when calling &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Open&lt;/SPAN&gt;&lt;SPAN&gt; on the &lt;/SPAN&gt;&lt;STRONG&gt;IName&lt;/STRONG&gt;&lt;SPAN&gt;-instance) in order to build the table locally or where exactly is this table created? Because of this error I left out the parameter and it works but for testing-purposes I´d like to see the data within the table also. So is this even possible when accessing a non-locale SDE?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all your hints so far&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 07:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451833#M12277</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2014-06-26T07:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451834#M12278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000006n8000000"&gt;IQueryName2.CopyLocally&lt;/A&gt;&lt;SPAN&gt; Property will copy your table into the scratch workspace in your system temp directory to assign ObjectID column to your result table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The ObjectID column is used for selections.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For more information check&lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0025000006n7000000"&gt; IQueryName2 Interface&lt;/A&gt;&lt;SPAN&gt; documentation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 08:02:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451834#M12278</guid>
      <dc:creator>AhmedEl-Sisi</dc:creator>
      <dc:date>2014-06-26T08:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451835#M12279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For some reason I get the &lt;/SPAN&gt;&lt;STRONG&gt;SEHException&lt;/STRONG&gt;&lt;SPAN&gt; -2147467259, no matter if &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;CopyLocally&lt;/SPAN&gt;&lt;SPAN&gt; is set to true or false so its no issue on right-access. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I have to consider a special syntax for the whereClause on an SDE which may differ from &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;Table.Field&lt;/SPAN&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Currently this is the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
/// &amp;lt;summary&amp;gt;
/// Virtually joins two tables
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="objectTable"&amp;gt;the businesTable&amp;lt;/param&amp;gt;
/// &amp;lt;param name="geometryTable"&amp;gt;the geometry-table where the shapes are stored&amp;lt;/param&amp;gt;
/// &amp;lt;param name="whereString"&amp;gt;an additional whereString to further specify the query&amp;lt;/param&amp;gt;
/// &amp;lt;param name="uuidField"&amp;gt;the identifier-field within the geometry-table (usually OFID) used for joining the tables&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;a FeatureClass that contains the the Objektart, the Modellart and the geometries of the joined tables&amp;lt;/returns&amp;gt;
/// &amp;lt;remarks&amp;gt;
/// The join is performed by evaluating the UUID-field of the object-table and the UUID-field of the geometry-table 
/// (while the former is already "UUID" the latter may vary).&amp;lt;br&amp;gt; /&amp;gt;
/// The returned featureClass contains the fields Modellart (MAT) and Objektart (OBA) from the objectTable and all fields of the geometry-table. 
/// &amp;lt;/remarks&amp;gt;
 
private IFeatureClass joinTables(string objectTable, string geometryTable, string whereString, string uuidField)
{
 // queryDef to perform a join on the object- and the geometry-table
 IQueryDef queryDef = ((IFeatureWorkspace)this.Workspace).CreateQueryDef();
 // select the Objektart (OBA), the Modellart (MAT) and all columns from the geometry-table (where the ESRI-feature is stored)
 queryDef.SubFields = objectTable + ".OBA," + objectTable + ".MAT," + geometryTable + ".*";
 queryDef.Tables = objectTable + "," + geometryTable;
 queryDef.WhereClause = objectTable + ".UUID = " + geometryTable + "." + uuidField; // the join-criterion

 IQueryName2 queryName2 = (IQueryName2)new FeatureQueryNameClass();
 queryName2.QueryDef = queryDef;
 //queryName2.PrimaryKey = geometryTable + "." + uuidField; // the ID-field of the FeatureClass
 //queryName2.CopyLocally = true;

 // Set the workspace and name of the new QueryTable.
 IDatasetName datasetName = (IDatasetName)queryName2;
 datasetName.WorkspaceName = (IWorkspaceName)(((IDataset)this.Workspace).FullName);
 datasetName.Name = "tmpTable";

 // Open the virtual table.
 ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)queryName2;
 return (IFeatureClass)name.Open();
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:09:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451835#M12279</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2021-12-11T20:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451836#M12280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have found that SQL queries directly to the SQL tables are much faster anyway, so often I will query directly from the SQL tables and extract unique IDs from the returned record set loading them into an array, then in a little loop build a selection string from that. I found it to sometimes be faster doing it that way?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;That´s more or less why I do at the moment because the alternative way by using &lt;/SPAN&gt;&lt;STRONG&gt;IQueryDef&lt;/STRONG&gt;&lt;SPAN&gt; won´t work (I already pointed the exception out in previous post). Actually I do a spatial query on my FeatureClass and select only the IDs of the features. Afterwards I put the list of the so obtained IDs into one (or more, depending on the length and the DBMS) whereClause for the attribute-query on the other table. Ofc. doing this by plain SQL might be much faster, but also much more complicated because of archieve-issues and I´d like to take the ArcGIS-way &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However I consider it more a workaround then the actual solution, so I´m still looking for the reason of this irritating exception. Does anyone have any similar problem on opening a virtual/temporal table?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Jul 2014 08:32:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451836#M12280</guid>
      <dc:creator>CarstenSchumann</dc:creator>
      <dc:date>2014-07-01T08:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Define a query for joining data</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451837#M12281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For some reason I get the &lt;STRONG&gt;SEHException&lt;/STRONG&gt; -2147467259, no matter if &lt;SPAN style="font-style:italic;"&gt;CopyLocally&lt;/SPAN&gt; is set to true or false so its no issue on right-access. &lt;BR /&gt;Do I have to consider a special syntax for the whereClause on an SDE which may differ from &lt;SPAN style="font-style:italic;"&gt;Table.Field&lt;/SPAN&gt;?&lt;BR /&gt;&lt;BR /&gt;Currently this is the code:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
/// &amp;lt;summary&amp;gt;
/// Virtually joins two tables
/// &amp;lt;/summary&amp;gt;
/// &amp;lt;param name="objectTable"&amp;gt;the businesTable&amp;lt;/param&amp;gt;
/// &amp;lt;param name="geometryTable"&amp;gt;the geometry-table where the shapes are stored&amp;lt;/param&amp;gt;
/// &amp;lt;param name="whereString"&amp;gt;an additional whereString to further specify the query&amp;lt;/param&amp;gt;
/// &amp;lt;param name="uuidField"&amp;gt;the identifier-field within the geometry-table (usually OFID) used for joining the tables&amp;lt;/param&amp;gt;
/// &amp;lt;returns&amp;gt;a FeatureClass that contains the the Objektart, the Modellart and the geometries of the joined tables&amp;lt;/returns&amp;gt;
/// &amp;lt;remarks&amp;gt;
/// The join is performed by evaluating the UUID-field of the object-table and the UUID-field of the geometry-table 
/// (while the former is already "UUID" the latter may vary).&amp;lt;br&amp;gt; /&amp;gt;
/// The returned featureClass contains the fields Modellart (MAT) and Objektart (OBA) from the objectTable and all fields of the geometry-table. 
/// &amp;lt;/remarks&amp;gt;
 
private IFeatureClass joinTables(string objectTable, string geometryTable, string whereString, string uuidField)
{
 // queryDef to perform a join on the object- and the geometry-table
 IQueryDef queryDef = ((IFeatureWorkspace)this.Workspace).CreateQueryDef();
 // select the Objektart (OBA), the Modellart (MAT) and all columns from the geometry-table (where the ESRI-feature is stored)
 queryDef.SubFields = objectTable + ".OBA," + objectTable + ".MAT," + geometryTable + ".*";
 queryDef.Tables = objectTable + "," + geometryTable;
 queryDef.WhereClause = objectTable + ".UUID = " + geometryTable + "." + uuidField; // the join-criterion

 IQueryName2 queryName2 = (IQueryName2)new FeatureQueryNameClass();
 queryName2.QueryDef = queryDef;
 //queryName2.PrimaryKey = geometryTable + "." + uuidField; // the ID-field of the FeatureClass
 //queryName2.CopyLocally = true;

 // Set the workspace and name of the new QueryTable.
 IDatasetName datasetName = (IDatasetName)queryName2;
 datasetName.WorkspaceName = (IWorkspaceName)(((IDataset)this.Workspace).FullName);
 datasetName.Name = "tmpTable";

 // Open the virtual table.
 ESRI.ArcGIS.esriSystem.IName name = (ESRI.ArcGIS.esriSystem.IName)queryName2;
 return (IFeatureClass)name.Open();
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; I tested this sample using SDE workspace and also GDB workspace and it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I used ArcObjects 10.1 +VS 2010 on windows 7 64-bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Similar exception found here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/22016-ArcMap-C-Integration-sometimes-gives-SEHException" rel="nofollow noopener noreferrer" target="_blank"&gt;http://forums.arcgis.com/threads/22016-ArcMap-C-Integration-sometimes-gives-SEHException&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/define-a-query-for-joining-data/m-p/451837#M12281</guid>
      <dc:creator>AhmedEl-Sisi</dc:creator>
      <dc:date>2021-12-11T20:09:52Z</dc:date>
    </item>
  </channel>
</rss>

