ColdFusion Programming/transferring data from database

Advertisement


Question
hi,

i want to know how to transfer data from database to the COLDFUSION?  
i tried to do it several times like below:
<cfquery name="patient" datasource="whatever">
SELECT *
FROM Patient
</cfquery>

<cfoutput query="patient">
#FirstName##LogonCode
</cfoutput>

but still what happens is when i tried to run it on the browser, rather than
showing the list from database, this is what happen:
#FirstName##LogonCode#


and i need to add new patient as well. thanks  

Answer
If that is your output then it means 1 of 2 things.
1 - You are not on a ColdFusion server
2 - Your page ends in html not cfm ex myPage.html vice myPage.cfm

To insert you have to have a form that takes the data and passes it to the query like

<cfquery name="qInsert" datasource = "myDatasource">
INSERT INTO table
(firstname,lastname)
VALUES
('#form.firstname#','#form.lastname#')
</cfquery>

ColdFusion Programming

All Answers


Answers by Expert:


Ask Experts

Volunteer


Donald Hammond

Expertise

Expert in ColdFusion, Flash ActionScript, XML, and SQL.

Experience

Cold Fusion, Flash Action Script

©2012 About.com, a part of The New York Times Company. All rights reserved.