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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

# in database field Coldfusion won't use

Status
Not open for further replies.

glebreck

IS-IT--Management
Nov 20, 2002
34
US
I have an AS400 DBase I am connection to. There are some fileds with "#" in. I.E. CUST#. When coded in coldfusion to display that part of the recordset it look s like this: #Recordset1.CCUST##. Obviously Coldfusion errors out when trying to display this. Is there a way to make it display?

Changing everything in the Dbase is not an option as there are to many programs running of of this!

Thanks
 
Can you ALIAS the Column Name in your query?

SELECT Cust# AS CustNo
 
I run into this with out AS/400 as well. I always just alias the column name in my query, as GTIMANiac said. Just make sure to add the extra # sign...
Code:
SELECT Cust## AS CustNo
This always seems to work for me.





Hope This Helps!

Ecobb

"My work is a game, a very serious game." - M.C. Escher
 
Ok that worked but now I nedd to make ccust# that i aliased as custno = to a url parameter.

select ccust## AS CustNo
From whereever
WHERE ccust# = #url.name#

select ccust## AS CustNo
From whereever
WHERE custno = #url.name#

Niether work!
 
Here is the error:

Invalid CFML construct found on line 16 at column 13.
ColdFusion was looking at the following text:
#


The error occurred in E:\Sites\Castle\test3.cfm: line 16

14 : </cfquery>
15 : <cfquery name="Recordset1" datasource="AS400" username="name" password="pass">
16 : SELECT CCUST#, CNAME, CADR2, CCITY, CSTATE, CZIP1, CPHONE, CTERM, CMAIL, CAGCUR, CAG030, CAG060, CAG090, CAG120, CZONE, CGUAR, CUPS, CSHIPV, CMAILS, CBUYER, COWNER, CSLSPR
17 : FROM QS36F.CUSTOMER
18 : WHERE CCUST# = #URL.custlist#


 
Is that your actual code, because I do not see the # escaped by a second #.
 
Sorry Actual code:
<cfquery name="Recordset1" datasource="AS400" username="glebreck" password="spankorla">
SELECT CCUST## AS CustNo, CNAME, CADR2, CCITY, CSTATE, CZIP1, CPHONE, CTERM, CMAIL, CAGCUR, CAG030, CAG060, CAG090, CAG120, CZONE, CGUAR, CUPS, CSHIPV, CMAILS, CBUYER, COWNER, CSLSPR
FROM QS36F.CUSTOMER
WHERE CCUST# = #URL.custlist#
</cfquery>

Error:
Invalid CFML construct found on line 18 at column 12.
ColdFusion was looking at the following text:
#


The error occurred in E:\Sites\Castle\test3.cfm: line 18

16 : SELECT CCUST## AS CustNo, CNAME, CADR2, CCITY, CSTATE, CZIP1, CPHONE, CTERM, CMAIL, CAGCUR, CAG030, CAG060, CAG090, CAG120, CZONE, CGUAR, CUPS, CSHIPV, CMAILS, CBUYER, COWNER, CSLSPR
17 : FROM QS36F.CUSTOMER
18 : WHERE CCUST# = #URL.custlist#
19 : </cfquery>
20 : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
 
In a <cfquery> or <cfoutput> CF is expecting #variable#, So you are getting the error from the CCUST#. Should Read as suggested above CCUST##. ## within a <cf> tag represents an actual '#'.

Code:
15 : <cfquery name="Recordset1" datasource="AS400" username="name" password="pass">
16 : SELECT CCUST##, CNAME, CADR2, CCITY, CSTATE, CZIP1, CPHONE, CTERM, CMAIL, CAGCUR, CAG030, CAG060, CAG090, CAG120, CZONE, CGUAR, CUPS, CSHIPV, CMAILS, CBUYER, COWNER, CSLSPR
17 : FROM QS36F.CUSTOMER
18 : WHERE CCUST## = #URL.custlist#

Should work with this code.

xtendscott
Web Site Design and CF Programming
 
How could I have missed that! Thanks much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top