cfsatx
asked on
Bind value is not a 2D array or valid serialized query
If I use cfinvoke, I am able to see the country code. But if I use CFSELECT with a bind, I get the bind value error. Please help. Thanks
dmis.cfc
<cfcomponent displayname="dmis" output="no">
<cffunction name="getCountry" hint="Gets all country codes from the database" returntype="query" access="remote">
<cfset var countrydata="">
<cfquery datasource="#TIMPOLookupDSN#" name="countrydata">
SELECT distinct Facility_Country_Code
FROM DMIS
where Facility_Country_Code is not null
ORDER BY Facility_Country_Code
</cfquery>
<cfreturn valueList(countrydata.Facility_Country_Code)>
</cffunction>
</cfcomponent>
test.cfm
<cfform>
<TR>
<TD align="right" nowrap>Country:</TD>
<TD>
<cfselect name="countrycode" bind="BBoard.cfc:dmis.getCountry()" bindonload="true" value="countrycode" />
</TD>
</TR>
</cform>
You're returning a comma delimited list of values from your cfc, you should return either an array or a query... try just returning countrydata
but also, a select requires two values, the Value and the Display. If DMIS has a primary key you should return that for the value... and the name of the country as the display.. that's two columns..
but also, a select requires two values, the Value and the Display. If DMIS has a primary key you should return that for the value... and the name of the country as the display.. that's two columns..
ASKER
I am using CF9...I changed my dmis.cfc and test.cfm just the same way you said. I still get the bind error. Thanks for your help.
dmis.cfc
<cfcomponent displayname="dmis" output="no">
<cffunction name="getCountry" hint="Gets all country codes from the database" returntype="query" access="remote">
<cfargument name="TIMPOLookupDSN" type="string" required="yes" default="TIMPO_Lookup_Dev_RW">
<cfset var countrydata="">
<cfquery datasource="#TIMPOLookupDSN#" name="countrydata">
SELECT distinct Facility_Country_Code
FROM DMIS
where Facility_Country_Code is not null
ORDER BY Facility_Country_Code
</cfquery>
<cfreturn countrydata>
</cffunction>
</cfcomponent>
test.cfm
<cfform>
<TR>
<TD align="right" nowrap>Country:</TD>
<TD>
<cfselect name="countrycode"
bind="BBoard.cfc:dmis.getCountry()" bindonload="true"
display="Facility_Country_Code"
value="Facility_Country_Code" />
</TD>
</TR>
</cfform>
What's the error? Also, what are the results if you call the function directly
ie http://yoursite.com/path/to/dmis/getCountry.cfc?method=getCountry
ie http://yoursite.com/path/to/dmis/getCountry.cfc?method=getCountry
ASKER
This is the error I am getting when I use CFSELECT bind
error:bind: Bind failed for select box countrycode,
bind value is not a 2D array or valid serialized query
I get country codes correctly when I call the function directly
mysite/dmis.cfc?method=get Country
error:bind: Bind failed for select box countrycode,
bind value is not a 2D array or valid serialized query
I get country codes correctly when I call the function directly
mysite/dmis.cfc?method=get
ASKER
How can I get rid of the bind error ?
> bind="BBoard.cfc:dmis.getC ountry()"
Just noticed the syntax for your bind is wrong. It should be:
bind="cfc:path.to.YourComp onent.meth odName()
So if your component is named "dmis.cfc" and is directly beneath the web root:
bind="cfc:dmis.getCountry( )"
Just noticed the syntax for your bind is wrong. It should be:
bind="cfc:path.to.YourComp
So if your component is named "dmis.cfc" and is directly beneath the web root:
bind="cfc:dmis.getCountry(
ASKER
I get CFC function not found in the bind expression
when I use bind="cfc:path.to.YourComp onent.meth odName()"
My .cfm and ,cfc are in the same folder
I use like this
bind="cfc:https://#cgi.SERVER_NAME#/TIMPODash/BBoard/dmis.cfc?method=getCountry"
when I use bind="cfc:path.to.YourComp
My .cfm and ,cfc are in the same folder
I use like this
bind="cfc:https://#cgi.SERVER_NAME#/TIMPODash/BBoard/dmis.cfc?method=getCountry"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked. Thanks for your help.
<cfselect name="countrycode"
bind="cfc:dmis.getCountry( )" bindonload="true"
display="Facility_Country_ Code"
value="Facility_Country_Co de" />
I am working on depending drop downs. Do you have any example? Selecting Country code should populate all states and selecting a state should populate all cities with in that...etc.,
<cfselect name="countrycode"
bind="cfc:dmis.getCountry(
display="Facility_Country_
value="Facility_Country_Co
I am working on depending drop downs. Do you have any example? Selecting Country code should populate all states and selecting a state should populate all cities with in that...etc.,
The function says it returns a query but returns a string instead. If you're using CF8.01 or higher, just return the whole query object.
<cfreturn countrydata>
</cffunction>
.. and use the query column name in your cfselect
<cfselect name="countrycode"
bind="BBoard.cfc:dmis.getC
display="Facility_Country_Code"
value="Facility_Country_Code" />