Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-25-2008, 04:03 AM   #1
maasss18
Registered User
 
Join Date: Jul 2008
Posts: 33
Red face Help. Handling Data.

Assuming my table has a field called Name with two record called David and Alan. I can insert 1 record called Alex using .cfc approach.

.cfc Approach
Code:
<cffunction name="oCreate" access="public" output="false" returntype="void">
<cfargument name="aObjectTest" type="ModelDb" required="true" />
		
<!--- var scope everything! --->
<cfset var insertObject = "" />
<cfset var getObjectID = "" />
			
<cftry>
<cftransaction action="begin"> 
<cfquery name="insertObject" datasource="#variables.dsn#">		
INSERT INTO Objects ( Name) 
VALUES ( 
<cfqueryparam cfsqltype="cf_sql_varchar" value="#aObjectTest.getName()#" maxlength="40" null="no">
</cfquery>
				
<cfquery name="getObjectID" datasource="#variables.dsn#">
SELECT @@identity as newObjectID
</cfquery>
					
<cfscript>
aObjectTest.setObjectID(getObjectID.newObjectID) ; 
</cfscript>
				
<cftransaction action="commit" />
</cftransaction>
			
<cfcatch type="database"> 			
<cftransaction action="rollback" />			
<cfthrow type="ModelDb.oCreate" message="#cfcatch.detail#" />	
</cfcatch>	
</cftry>
</cffunction>
I want to retrieve back all the records to display it in a comboBox using a .cfc aproach.

Currently i can only see the 2 records in the combobox, David and Alan using .cfm approach. I could not see Alex. Not sure if the table is refresh.

.cfm Approach to retrieve all the records
Code:
<cfprocessingdirective suppresswhitespace="yes" pageencoding="utf-8">

<cfquery name="getObjToVar" datasource="testdb3">
SELECT Name FROM Objects 
</cfquery>

<cfxml variable="dataXML">
<posters>
	  		
<cfloop query="getObjToVar">
<pos> 
<cfoutput>#Name#</cfoutput>
</pos>
</cfloop>
				
</posters>  
</cfxml>

<cfoutput>#dataXML#</cfoutput>
</cfprocessingdirective>
HTTPService in .mxml application
Code:
<!-- Setup the connection to the Coldfusion CFM - Data.cfm -->
<mx:HTTPService id="dataRequest" resultFormat="e4x" method="POST"
url="http://localhost:8500/Wimeals/src/Database/Data.cfm">
</mx:HTTPService>
ComboBox code
Code:
<mx:ComboBox id="cBoxObject" dataProvider="{dataRequest.lastResult.pos}" change="{getImagePath()}" /  >

Does .cfc allow us to retrieve a set of records inclusive of the latest inserted records?

Last edited by maasss18; 09-25-2008 at 09:30 AM.
maasss18 is offline   Reply With Quote
Old 09-25-2008, 05:42 PM   #2
solisarg
Senior Member
 
solisarg's Avatar
 
Join Date: Mar 2003
Location: Buenos Aires, Argentina
Posts: 496
Default

To use an HTTPService you should call somewhere. Once you update the table, you should call it again (probably adding some random in the URL to avoid cache)
solisarg is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling data out of array Cainnech ActionScript 2.0 2 05-05-2008 12:44 AM
handling dynamic data blueshades ActionScript 1.0 (and below) 1 05-30-2006 01:33 AM
problem splitting up data with param string oatesj77 ActionScript 2.0 1 03-31-2006 03:13 AM
Dynamic data with flash emilioestevezz ActionScript 2.0 2 11-03-2004 05:39 AM
Database simulated with arrays on a cd-rom lecasn5 Components 61 09-07-2004 11:40 AM


All times are GMT. The time now is 09:29 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.