In your guestbook-database you should have a primary key; a field that
identifies each record in the database. In this example, this is "The_ID":
<cfquery name="guest" datasource="YourDatasource">
SELECT The_ID, TheTitle, TheText (Replace these with your actual
fieldnames)
FROM YourTable
ORDER BY The_ID
</cfquery>
If you append DESC to the order by-line, then the records will be sorted
with the last records first.
The max()-function in SQL is only designed to get the highest value of one
field. Useful for getting the ID of the last record added to the database.
rgds
* Holger Lockertsen, Solutions Developer, Horisont Information Systems AS
* Nedre Slottsgate 5, N-0157 OSLO, Noreg/Norway
* 23 31 03 04 / 91 83 20 51
* [EMAIL PROTECTED] http://www.horisont.no/
NB! Horisont har f�tt nye nummer, og mitt INTERNNUMMER er: 23 31 03 04
> -----Original Message-----
> From: Splash! Designs Ink. [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 23, 2000 6:33 AM
> To: [EMAIL PROTECTED]
> Subject: Problem with Query command
>
>
> Hello,
> I am new to Coldfusion, and have been working on
> a simple guestbook. I followed through the tutorials
> that came with CFExpress and had no problems setting
> up a database, form and outputting the data until I
> tried to format the data in descending order (last entry
> to the first entry).
> I tried some create ways with CFSET & counting
> the total records, then tried using CFQUERY STARTROW
> , but this didn't work. I read through all of the various CFML
> commands & tried to find one that would do this. Finally, I resorted
> to SQL commands and found ORDER BY.... ASC/DESC.
> This, however, only worked when a field name was
> given, so I gave up & decided to look at someone else's
> CFML guestbook.
>
> I found one located at:
> http://www.iiseutu.fi/cfdocs/Docs/UGuide/UserGuide.htm
> In the action page, there was reference to the automated ID in the
> database, but when I tried to run this code, I got the error message
>
> ODBC Error Code = 07001 (Wrong number of parameters)
>
> SQL = "SELECT MAX(guestbook_ID)AS ID FROM guestbook"
>
> The code that in error is:
>
> <CFQUERY NAME="GetEnteredRecordID" DATASOURCE="GFGuestbook1">
> SELECT MAX(guestbook_ID)AS ID FROM guestbook
> </CFQUERY>
>
> Can anyone shed some light on this problem? I'm running CFExpress locally
> and have had no problems with the basic forms.
>
> Thanks so much,
> Kristin Thu
> [EMAIL PROTECTED]
>
>
>
>
> ------------------------------------------------------------------
> ------------
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.