Skip to main content
nikos101
Inspiring
March 16, 2009
Question

What is the best way to sent the data to coldfusion and then from coldfusion to the database?

  • March 16, 2009
  • 3 replies
  • 819 views
Hi All :)

Thanks to all the very helpful people in this forum who have helped me so much already.

I have a flex datagrid which a user populates and then sends to coldfusion to be stored in a mssql.

What is the best way to sent the data to coldfusion and then from coldfusion to the database?
This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
March 29, 2009
The error suggests the Flex client is sending a structure to the function, not an array as you expect.

nikos101
nikos101Author
Inspiring
March 17, 2009
I've tried to do something like this?

In the flex:

private function submitData():void
{
myService.saveStorages(storages.source);
}

In the CF:
<cffunction name="saveStorages" access="remote" returntype="boolean">
<cfargument name="arrData" type="Any" required="yes">
<cfset i = 1>


<cfloop condition="i LESS THAN OR EQUAL TO #ArrayLen(arrData)#">



<cfquery name="q" datasource="ds">



insert into Storage

values
(
<cfqueryparam value="#arrData [1]#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#arrData
[2]#" cfsqltype="cf_sql_integer">,
<cfqueryparam value="#arrData [3]#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#arrData
[4]#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#arrData [5]#" cfsqltype="cf_sql_bit">,
<cfqueryparam value="#arrData
[6]#" cfsqltype="cf_sql_varchar">
)
</cfquery>

<cfset i = i + 1>
</cfloop>




<cfset flash.result=true>
<cfreturn flash.result>

</cffunction>

but I see nothing in the database but get an error returned to flex:(

faultCode:Server.Processing faultString:'Element 1 is undefined in a CFML structure referenced as part of an expression.' faultDetail:''
nikos101
nikos101Author
Inspiring
March 17, 2009
I think I've figured out how to sent the array collection data to cold fusion. However I am not sure of the best way to save this data to the mssql database.

Any ideas?
Inspiring
March 22, 2009
quote:

Originally posted by: nikos101
I think I've figured out how to sent the array collection data to cold fusion. However I am not sure of the best way to save this data to the mssql database.

Any ideas?

Loop through the array. Do whatever validation and other processing you have to do on each row and then write an insert query.