Search code examples
coldfusionapplication.cfc

Coldfusion Application.cfc


This may be a stupid question, but when my datasource is in a cfm page it will work just fine, but when I put the datasource in my application.cfc it errors out.

Code from CFM file

<cfquery name = "getlist" datasource="jeb48_shoppingcart">
 SELECT ProductID, ProductName, ProductQty, ProductPrice, ProductDescription
 FROM Products;
</cfquery>

Code from CFC

<cfcomponent> 
   <cfset This.name = "TestApplication"> 
   <cfset This.clientStorage = "jeb48_northwind"> 
   <cfset This.clientmanagement="True"> 
   <cfset This.loginstorage="Session"> 
   <cfset This.sessionmanagement="True"> 
   <cfset This.sessiontimeout="#createtimespan(0,0,10,0)#"> 
   <cfset This.applicationtimeout="#createtimespan(5,0,0,0)#"> 
</cfcomponent>

Solution

  • Your Application.cfc is not setting the datasource correctly.

    clientstorage is used by client variables - read more about that here

    datasource is used for cfquery datasources:

    <cfset this.datasource="cfartgallery">

    You can read more about the datasource property here