IRelationshipClassCollection relClassCollection = (IRelationshipClassCollection)fl; IEnumRelationshipClass relClasses = relClassCollection.RelationshipClasses; IRelationshipClass rc = null; while ((rc = relClasses.Next()) != null) { ISet relSet = rc.GetObjectsRelatedToObject(f); IRowBuffer rowBuffer = null; while ((rowBuffer = (IRowBuffer)relSet.Next()) != null) {...
Has anyone been successful getting relates to work in the Flex Sample Viewer?What I want is for the user to be able to click on a fire hydrant and get information from a related table, such as fire flow test info.If anyone has an example of this please point me to the sample or post it on the Flex API resource page.Thanks.-Will
[WebMethod(Description = "Returns Flow Control History Details")] public DataTable FlowControlHistory(String objectID) { DataTable FlowTable = new DataTable(); System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection("<your connection string here>"); connection.Open(); // build a sql expression to access your database data // using a passed OBJECTID from a feature in flex string strSQL = "SELECT DISTINCT t1.FLOWID " + "FROM sde.SSCOMPLEXFLOWCONTROLHISTORY as t1 " + "WHERE t1.OBJECTID = '" + objectID + "' " + "UNION " + "SELECT DISTINCT t2.FLOWID " + "FROM sde.SSFLOWCONTROLHISTORY as t2 " + "WHERE t2.OBJECTID = '" + objectID + "' " + "ORDER BY FLOWID; System.Data.OleDb.OleDbDataAdapter Adapter = new System.Data.OleDb.OleDbDataAdapter(strSQL, connection); Adapter.Fill(FlowTable); try { FlowTable.TableName = "Table"; } finally { connection.Close(); } return FlowTable; }
protected var service:WebService; protected var retry:uint = 0; // send your Web Service WSDL to define a web service public function setWsdl(value:String):void { service = new WebService(); service.showBusyCursor = true; service.wsdl = value; service.addEventListener(FaultEvent.FAULT, WsdlFault, false, 0, true); service.loadWSDL(); } protected function onWsdlFault(fault:FaultEvent, token:Object = null):void { // I always try to load a web service twice if I get a load error. // Just in case, my network can laugh at me sometimes retry++; if (retry < 2) service.loadWSDL(); else { service.removeEventListener(FaultEvent.FAULT, WsdlFault); Alert.show("A Web Service has failed to load. Please close the application and try again.", "Error"); } } // function that will call my web service public function findRelatedFlowData(objectID:String):void { var responder:AsyncResponder = new AsyncResponder(onFlowDataResults, onFault); var request:AsyncToken = service.FlowControlHistory(objectID); request.addResponder(responder); } proteced function onFlowDataResults(result:ResultEvent, token:Object = null):void { var ac:ArrayCollection = result.result.Tables.Table.Rows; // do something with results here } protected function onFault(fault:FaultEvent, token:Object = null):void { // I always try to load a web service twice. Alert.show("A Web Service error has occurred.", "Error"); }
** edit, just saw that last comment you posted above.In my experience, a Web Service is quick, easy and usually a great tool for accessing external data.You could create a web service using a .NET flavor of your choice that will query your SDE or any other db to simulate your relate. Pass it a name, id, whatever. It may be a little slow depending on size of results. I've used this method for a couple of years and it works fine. Typical method for above scenario.Select graphic on map (you could also do this after getting Identify results if you'd like)Pass attribute field value to web serviceUse service response to populate List/DataGridA web service is pretty simple to set up in .NET and the code is pretty easyhttp://msdn.microsoft.com/en-us/library/8wbhsy70.aspxSimplest route is to return a DataTable and in flex that will be returned as an ArrayCollection that will look like event.result.Tables.<TableNameHere>.RowsA benefit of doing the queries this way is that you can perform any JOINS/UNIONS or changing of field names that you may want to pass to your application to make things easier on yourself.
Relates won't work with 9.3.1 as the relationship is not recognized via the REST service.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.