120
Chapter 10: Lesson 6: Adding and Updating SQL Data
Tip:
To save time, you can copy this code from the tripsinsertquery.txt file (for Windows users) or
from tripinsertqueryunix.txt (for UNIX users) in the solutions directory.
3
Save the page and test it by opening the tripedit.cfm page in your browser.
For Code
Windows users,
using MS Access
<!--- Insert the new trip record into the Compass
Travel Database --->
<cfquery name="AddTrip" datasource="compasstravel">
INSERT INTO Trips (tripName, eventType, tripDescription,
tripLocation,departureDate, returnDate, price, tripLeader,
photo, baseCost, numberPeople, depositRequired)
VALUES ('#Form.tripName#', #Form.eventType#,
'#Form.tripDescription#',
'#Form.tripLocation#','#Form.departureDate#',
'#Form.returnDate#',
#Form.price#, '#Form.tripLeader#', '#Form.photo#',
#Form.baseCost#, #Form.numberPeople#,
'#Form.depositRequired#')
</cfquery>
UNIX users, using
PointBase
<!--- Insert the new trip record into the
Compass Travel Database --->
<!--- Use local variables to convert dates to JDBC format
(yyyy-mm-dd) from input format (mm/dd/yyyy) --->
<cfset JDBCdepartureDate = #Right(Form.departureDate,4)#
& "-" & #Left(Form.departureDate,2)# & "-"
& #Mid(Form.departureDate,4,2)#>
<cfset JDBCreturnDate = #Right(Form.returnDate,4)# & "-"
& #Left(Form.returnDate,2)# & "-"
& #Mid(Form.returnDate,4,2)#>
<cfquery name="AddTrip" datasource="CompassTravel">
INSERT INTO Trips (tripName, eventType,
tripDescription, tripLocation,
departureDate, returnDate, price, tripLeader, photo,
baseCost, numberPeople,depositRequired)
VALUES ('#Form.tripName#', #Form.eventType#,
'#Form.tripDescription#',
'#Form.tripLocation#', Date'#JDBCdepartureDate#',
Date'#JDBCreturnDate#',
#Form.price#,'#Form.tripLeader#', '#Form.photo#',
#Form.baseCost#, #Form.numberPeople#,
'#Form.depositRequired#')
</cfquery>
Содержание COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 30: ...30 Chapter 2 CFML Basics...
Страница 36: ...36 Chapter 3 Database Fundamentals...
Страница 48: ......
Страница 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Страница 134: ...134 Index...