0
votes

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>
2
For next time, "errors out" is very vague. If you are getting an error, please include the actual error message. - Leigh
Did you try changing the order and setting clientmanagement before setting clientStorage? Also make sure your database is configured for client variables, see: help.adobe.com/livedocs/coldfusion/8/htmldocs/… Make sure you setup the CDATA and CGLOBAL tables as outlined in the link above. - osekmedia

2 Answers

9
votes

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

0
votes

One solution would be to define your datasource as an application variable witin your onapplication start. If you have multiple datasources you could use an application variable containing a structure of datasources. Antony is correct, you are only creating a reference to the datasource for client storage. This does not mean it works.

<cfset APPLICATION.dsn = {}>
<cfset APPLICATION.dsn.main = "jeb48_northwind">
<cfset APPLICATION.dsn.logging = "loggingDataSource">

<cfquery name = "getlist" datasource="#APPLICATION.dsn.main#">
SELECT ProductID, ProductName, ProductQty, ProductPrice, ProductDescription
FROM Products;
</cfquery>