Jump to content
Software FX Community

Unable to Execute a query with Conn.Execute in Cold Fusion


User (Legacy)

Recommended Posts

<CFINCLUDE template="/Include/CfxIE.cfi">

<!--- Create the ChartFX Server Object --->

<CFOBJECT ACTION="Create" NAME="Chart" CLASS="ChartFX.WebServer">

<!--- Set the UserAgent property to allow browser detection --->

<CFSET Chart.UserAgent=#HTTP_USER_AGENT# >

<!---Create the ADODB Connection and query the database--->

<CFOBJECT ACTION="CREATE" NAME="Conn" CLASS="ADODB.Connection">

<!---Open the ODBC data source--->

<CFSET Conn.open("DSN=MyDB;","UID","PSW","0")>

<cfset MyQuery = "select * From marketdata">

<!---Execute the SQL statement that will return the data--->

<CFSET RS=Conn.Execute("#MyQuery#","","0")>

<cfoutput> #RS.recordcount#</cfoutput>

<!---Assign the contents of the ResultSet to the Chart--->

<CFSET Chart.AdoResultset(RS)>

<!---Close The Connection--->

<CFSET Conn.Close()>

<!--- The next line will generate the HTML tag --->

<CFOUTPUT> #Chart.GetHtmlTag(970,500)# </CFOUTPUT>

This was working for a while. Now the code above returns a -1 for

RS.recordcount and generates the default chart. It seems like it is not

able to execute the query, however if i put in an incorrect table name I get

an error at the execute line telling me that the table was not found.

Link to comment
Share on other sites

Did you check if your table contains data ? Maybe your DSN is pointing to a

different server/database ?

--

Regards

JC

Software FX Support

"Brandon Gable" <brandon.gabel@gadberry.net> wrote in message

news:fE6h2s86BHA.1268@webserver1.softwarefx.com...

> <CFINCLUDE template="/Include/CfxIE.cfi">

>

> <!--- Create the ChartFX Server Object --->

> <CFOBJECT ACTION="Create" NAME="Chart" CLASS="ChartFX.WebServer">

>

> <!--- Set the UserAgent property to allow browser detection --->

> <CFSET Chart.UserAgent=#HTTP_USER_AGENT# >

>

> <!---Create the ADODB Connection and query the database--->

> <CFOBJECT ACTION="CREATE" NAME="Conn" CLASS="ADODB.Connection">

>

> <!---Open the ODBC data source--->

> <CFSET Conn.open("DSN=MyDB;","UID","PSW","0")>

>

> <cfset MyQuery = "select * From marketdata">

>

> <!---Execute the SQL statement that will return the data--->

> <CFSET RS=Conn.Execute("#MyQuery#","","0")>

>

> <cfoutput> #RS.recordcount#</cfoutput>

>

> <!---Assign the contents of the ResultSet to the Chart--->

> <CFSET Chart.AdoResultset(RS)>

>

> <!---Close The Connection--->

> <CFSET Conn.Close()>

>

> <!--- The next line will generate the HTML tag --->

> <CFOUTPUT> #Chart.GetHtmlTag(970,500)# </CFOUTPUT>

>

>

>

> This was working for a while. Now the code above returns a -1 for

> RS.recordcount and generates the default chart. It seems like it is not

> able to execute the query, however if i put in an incorrect table name I

get

> an error at the execute line telling me that the table was not found.

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...