Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-10-2009, 02:28 PM   PM User | #1
malcomhfc
New to the CF scene

 
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
malcomhfc is an unknown quantity at this point
flex to database.

Hey everyone. Im trying to find away to, when someone fill's out a form and push enter, the info is stored into a sql database of which i can display the data, say so someone can view using a php script.

The part im stuck at is how i manage after submit button being pushed, flex connects to a sql database and uploads into the specified tables.

If that's to complicated, is there a easy feature like send info by mail?

Im new to flex and im looking to use this feature in one of my apps im creating

Thanks in advance,

Malcom
malcomhfc is offline   Reply With Quote
Old 06-14-2009, 08:01 PM   PM User | #2
loki421
Regular Coder

 
Join Date: Feb 2009
Location: Worcester
Posts: 172
Thanks: 13
Thanked 6 Times in 6 Posts
loki421 is an unknown quantity at this point
Hi,

You'd use a function to send the relevant fields back to the server where it's handled.

here's an example:

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.rpc.events.ResultEvent;
			import mx.rpc.events.FaultEvent;
		
		
			private function insertRecord(event:MouseEvent):void
			{
				ro.InsertRecord
				(someValue.text,
				someMore.text,
				bitMore.text);
				Alert.show('You have successfully added this record.');
			}
			
			private function myFaultHandler(event:FaultEvent):void
			{
				Alert.show(event.fault.faultString, event.fault.faultCode);
			}
			
			private function myResultHandler(event:ResultEvent):void
			{
				//whatever result you want in here....
			}
			
			
		]]>
	</mx:Script>
	
	<mx:RemoteObject id="ro" destination="ColdFusion" source="flex3.myCFC" showBusyCursor="true" >
		<mx:method name="InsertRecord" result="myResultHandler(event)" fault="myFaultHandler(event)" />
	</mx:RemoteObject>
	
	<mx:HBox width="392" height="113">
		<mx:VBox width="100" height="100" horizontalAlign="right">
			<mx:Label text="Some data"/>
			<mx:Label text="some more data"/>
			<mx:Label text="bit more data"/>
		</mx:VBox>
		<mx:VBox width="259" height="100">
			<mx:TextInput id="someValue"/>
			<mx:TextInput id="someMore"/>
			<mx:TextInput id="bitMore"/>
		</mx:VBox>
	</mx:HBox>
	<mx:Button label="Add record" click="insertRecord(event)"/>
</mx:Application>
That's just a basic app, you'd then handle the data on the server, this example is using ColdFusion, but all you have to change is the Remote Object or change it to a http request.

If you were using CF to handle the data it would go something like this:
Code:
<cffunction name="InsertRecord" access="remote" returntype="Any">
	
	<cfargument name="someValue" type="string" required="yes">
	<cfargument name="someMore" type="string" required="yes">
	<cfargument name="bitMore" type="string" required="yes">
	
	<cfquery  name="qInsert" datasource="#myDSN#">
	INSERT INTO #myTable# (column1,
	column2,
	column3)
	VALUES  (
	'#arguments.someValue#', 
	'#arguments.someMore#', 
	'#arguments.bitMore#')
	</cfquery>

	</cffunction>
That would obvioulsy be in your CFC.

Anyway, hope this sheds some light on the subject for you
loki421 is offline   Reply With Quote
Old 06-16-2009, 03:15 AM   PM User | #3
BWiz
Regular Coder

 
BWiz's Avatar
 
Join Date: Mar 2006
Location: Sol System
Posts: 471
Thanks: 7
Thanked 21 Times in 21 Posts
BWiz is an unknown quantity at this point
I'm actually writing an application which does the very thing you are trying to achieve. Instead of using ActionScript to connect to the database, however, I used PHP. The Flex frontend sends data to the PHP script using <mx:HTTPService>.

This is the part I'm still working on: the PHP script sends back a response to the Flex application using XML, telling the application what happened (i.e. if the data injection was successful, if it failed, if there are any fields which are left blank etc.)

But it definitely is possible. If you want to see the source, just ask.
__________________
BWiz :: Happy Coding!
2006
2007 2008 2009
2010 2011
Irrational numbers make no sense.
BWiz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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


All times are GMT +1. The time now is 12:15 AM.


Advertisement
Log in to turn off these ads.