7 Replies Latest reply on Jan 9, 2007 10:52 AM by Route 66

    Passing Database Query using ColdFusion

    Route 66

      I'm having a terrible time trying to figure out how make Flex access information from a database via a ColdFusion CFC. I have yet to find a good example of how this is accomplished. My company's development server is running ColdFusion MX 6.1 and I am using Flex Builder 2.

      I'm using the OWS (Orange Whip Studio) database that accompanies the CF development book to do my testing. Here is the code I have been trying to work with.

      ColdFusion CFC:
      <cffunction name="getDirectors" access="remote" returntype="query" >
      <cfquery name="directors" datasource="ows" >
      select *
      from directors
      order by lastname
      <cfreturn directors>

      MXML code:
      import mx.rpc.events.ResultEvent;
      import mx.collections.ArrayCollection;
      import mx.controls.Alert;

      private var directors:Array;

      private function directorHandler(event:ResultEvent):void{
      directors = event.result as Array;

      <mx:WebService id="PubDataRPC"
      wsdl=" http://localhost:8500/TestFlex/PubData.cfc?wsdl" showBusyCursor="true" >
      <mx:operation name="getDirectors" result="directorHandler(event)" fault="Alert.show(event.fault.message)"/>

      <mx:DataGrid dataProvider="{directors}">
      <mx:DataGridColumn dataField="directorid"/>
      <mx:DataGridColumn dataField="firstname"/>
      <mx:DataGridColumn dataField="lastname"/>

      The above code returns a datagrid but without any row information being displayed. The strange thing is that the datagrid has a scroll bar like the data should be there, but it isn't.

      Any help (especially sample code) would be appreciated.