Groups | Blog | Home
all groups > flash data integration > may 2005 >

flash data integration : INSERTing record into Access



kadman
5/24/2005 12:00:00 AM
Fellow Flashers,

I posted a very similar message to the ColdFusion and Flash integration board
last week, but got no responses,so thought I might be barking up the wrong
tree. I now turn to the Flash side of the fence to see whether or not there
were any pointers or tutorials you folks might recommend to accomplish what
seemed like a simple and straightforward task.

The only documentation I have seen in either print or electronic format refers
to tackling this using Actionscript 1.0. With the advent of the latest
generation of AS, the amount and structure of coding has greatly changed, so I
would prefer to keep with the rest of my application's coding conventions and
components.

I have a Cold Fusion Component (with Access=remote) that will insert a six
field record into an Access database. I have tested the CFC from a ColdFusion
page, using an SQL statement using <cfinsert> tags in the .cfc (to allow for
optional fields). Anyhow, this works just fine, so I figure that the issue is
arising in the remoting from my flash movie. I have managed to use other CFC's
with SELECT statements to dynamically populate a number of controls within the
flash movie, so I can get to the data in other tables within this target
database, but when I try to invoke the webservice I have defined pointing to
the .cfc with the INSERT method, nothing seems to happen. I have named the
fields in the flash movie the same as the fields in the .cfc file.

The enviroment is AS2, Flash MX Pro 2004, CFMX7, Access 2000.

I guess what I should be asking is how to make a call from the flash movie to
the .cfc containing the INSERT statement? I had relied on a simple trigger tied
to a button click or an onLoad event to initiate a defined webservice for the
..cfc's containing the SELECT statements. Is there added information I need to
supply somewhere when trying to do an INSERT?

I hope you folk have a deeper understanding/willingness to share. Any tips
would be sincerely appreciated.

-kadman
adireddy
5/25/2005 12:00:00 AM
You can use LoadVars class to communicate with coldfusion.

kadman
5/25/2005 12:00:00 AM
Adi,

Thank you for your response.

I read your tutorial on using LoadVars that you suggested. I agree that going
that route is an option, but I was hoping that by having access to the latest
of Macromedia's technologies performing tasks such as this would have been
simplified compared to previous methods for doing this. You alluded to this in
the conclusion of your piece when you recommended using WebServices Connector
Component in Flash MX Pro 2004 as a solution for complex data communication.

This is the path down which I had been proceeding, as I have created several
web services for remotely calling Cold Fusion Components to SELECT recordsets
for some controls within this application. As I have already created an INSERT
web service Component, which has been tested from a Cold Fusion page, I thought
all I would have left to do is send data from my Flash app through that .cfc
defined webservice. It seems as if there is a piece I am overlooking. Have
you (or anyone else) had experience with performing such an operation?

-kadman
adireddy
5/25/2005 12:00:00 AM
WebService Connector Component in Flash MX Pro 2004 is an easy to use
component. You can try it on your own. Just drag the component on to the stage
and set the properties. You can refer to the help section under using
components -> components dictionary to know more about this component.
kadman
5/25/2005 12:00:00 AM
Adi,

Again, thanks for your willingness to respond.

The issue I think I am having related to the use of the Web Service Component
is limited to an INSERT task. I have used other Web Service Component
instances throughtout the application for dynamically populating controls with
data from the server. Where the rub seems to be is in getting data to go the
other direction. Have you (or anyone) been able to send control values to the
server via an INSERT SQL statement (in this case) residing in a Cold Fusion
Component that is the Web Service?

Am I making this clearer?

-kadman
adireddy
5/26/2005 12:00:00 AM
Sorry, I am not clear what exactly you are looking for...

kadman
5/26/2005 12:00:00 AM
Adi,

What I am trying to say is that I have some combobox and some text input
controls on a form. The comboboxes are dynamically populated via data retrived
from the server using a Web Service Connector that calls to a Cold Fusion
Component containing a SELECT statement - no problem. However, the text inputs
contain values that the user has entered and it is these control values I am
trying to send off via a mechanism similar to that I am currently using for the
combobox controls, just headed the other direction (TO as opposed to FROM) the
server.

Does that explain it better?

-kadman
adireddy
5/27/2005 12:00:00 AM
kadman
5/27/2005 12:00:00 AM
Adi,

You have it right. All I am trying to do is to pass a few user-entered values
from text input controls in my Flash movie via a CF Component that is defined
as a Web Service and registered with the application through the web services
panel to a an Access database where they are to be inserted as a new record.

You have done (or know how to do) something like this?

-kadman
adireddy
5/27/2005 12:00:00 AM
Yes...

You can send values using the params property of the webservice connector
component.

wsc.params = [val1,val2,val3,.....];

"wsc" is the instance name of the webservice connector component and you can
specify the values you want to send inside the square brackets as shown above
sperated by comma.
doof moof
5/27/2005 12:00:00 AM
I am having the exact same problem. I can get the data from the access db into
flash using the SELECT thing. but when i try to pass a string from the text
input components to the cfc which uses INSERT INTO to update the db with these
strings, the out going connector wont connect, its like the web service
connector component is a one way conector. one way i have found aroud this is
to use action script to set up the connection and send the variables. this
seams to work to get them to send. however when i use this method another error
occurs in that the cfc says that the variables passed to the cfargument are
"not of type string".
All in all using the web service connector component is deffinatly the
simplest way about this task, though with the big exception of the above
mentioned poblem (which i belive we have in comon).
Perhaps there is somthing which has to be done to set the connector components
direction to out (but what)?
If i find the answer i will be sure to post it here for you to read, and like
wise will check back regually for any other updates.
kadman
6/16/2005 12:00:00 AM
Adi, doof, et.al.,

After significant wailing and gnashing of teeth, I have managed to get my
sample app working. Adi was kind enough to point me in the right direction, as
the first of the problems dealt with the parameters being sent from the Flash
movie. Once I had the proper parameters defined in the Web Services Connector
Component's "schema" tab and matched them up with the <cfargument> tags values
as defined in the .cfc, I was on my way. However, I ran into one more "gotcha"
along the path. This involved the primary key field in the database. It was
of type "autonumber" and it caused me fits. It wasn't until I had removed or
changed that field to another data type that I was able to finally get the data
in.

Thanks to you both for your willingness to help.

--kadman
sacal
7/12/2005 8:49:48 PM
Maybe somebody here can help me.

I'm trying to pass values from flash to mySQL via coldFusion. Here's my Flash
code:


//--- params to send to DB ---//
params = new Array();
params[0] = System.capabilities.os; //userOS
params[1] = System.capabilities.version; //flash plug-in
params[2] = viewDate; //today's date
params[3] = startTime; //start time
params[4] = endTime; //end time

//-- connecting --//
NetServices.setDefaultGatewayUrl(gatewayURL);
var gw = NetServices.createGatewayConnection();
var server = gw.getService("insertRecord", new Result());
server.newRecord(params);


--------------------------------------------------------------------------------
---------------
And here's the CF code:

<cfcomponent name="insertRecord">

<cffunction name="newRecord" access="remote">

<!-- params from FLASH -->
<cfset userOS=flash.params[1]>
<cfset plugin=flash.params[2]>
<cfset sessionDate=flash.params[3]>
<cfset startTime=flash.params[4]>
<cfset endTime=flash.params[5]>

<cfset localIP=cgi.REMOTE_ADDR>
<cfquery name="addUserInfo" datasource="dbusertracking">
INSERT INTO tb_user
VALUES ('#localIP#', '#userOS#', '#plugin#', #sessionDate#',
'#startTime#', '#endTime#', '#localIP#)
</cfquery>
<cfset sendStatus='new record added'>
<cfreturn #sendStatus#>

</cffunction>

</cfcomponent>


--------------------------------------------------------------------------------
---------------
When I run this, the Netconnection Debugger shows me the parameters being sent
when the connection is called, but the final status report"s:

Status (object #2)
.....code: "Server.Processing"
.....description: "Complex object types cannot be converted to simple values."
.....details: ""
.....level: "error"
.....type: ""
.....rootcause (object #3)
..........code: (undefined)
..........description: "Complex object types cannot be converted to simple
values."
..........details: ""
..........level: "error"
..........type: ""

Looks like I'm having variable type conflicts. How do I fix it?

Thanks alot for any help!!!
M&M

AddThis Social Bookmark Button