Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query a SQL Server

Status
Not open for further replies.

fiber0pti

ISP
Nov 22, 2000
96
US
I'm trying to do a simple query on a SQL server with CF. No matter what variable I do it says that that variable does not exsist. My code is:
<cfquery name=&quot;testing&quot; datasource=&quot;vizeon&quot; dbtype=&quot;ODBC&quot; username=&quot;administrator&quot; password=&quot;<password>&quot;>
SELECT *
from products
</cfquery>
<cfoutput>#products.CatID#</cfoutput>

Everything works fine until the CFOUTPUT. It doesn't recognize any of the table columns from the table &quot;products&quot;. Am I doing something wrong?
 
rewrite the query like this

<cfquery name=&quot;testing&quot; datasource=&quot;vizeon&quot; dbtype=&quot;ODBC&quot; username=&quot;administrator&quot; password=&quot;<password>&quot; debug=&quot;Yes&quot;>
SELECT *
from products
</cfquery>
<cfoutput>#testing.CatID#</cfoutput>

or

follow these steps:

1. Specify in your CF Admin the user name and password for the datasource you are trying to use.
2. rewrite the query above with a debug option enabled and no username and password (this should work as you have enabled them in the Admin area).
3. Output the query
<CFOUTPUT QUERY=&quot;TESTING&quot;>#CatID#</CFOUTPUT>

HTH

Amit
 
If you're still having problems, write the &quot;FROM&quot; portion of your query using this format:

FROM .databaseName.dbo.tableName

Kevin
slanek@ssd.fsi.com
 
<cfoutput>#products.CatID#</cfoutput> ---- this is wrong, you should not use the table name, rather use need to use the query name mention in the cfquery attribute, like this

<cfoutput>#Testing.CatID#</cfoutput>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top