this may also be useful to someone,
re Terry's
<cfif myQuery.yourCountField_or_recordCount> to test for true/false
in the cfquery I add maxrows=1, thats all I need for a true condition,
doesn't matter if 1 or more rows are returned, its still true. But I don't
know how efficient or inefficient maxrows is, I'm guessing its more
efficeint to get one record from the db than say 50 or 500 etc.
-steve
terry@greatgulfh
omes.com To: [EMAIL PROTECTED]
Sent by: cc:
owner-cfug@cfugt Subject: RE: [CFTALKTor] Check
Existing Date in
oronto.org Database
06/13/02 07:04
AM
Please respond
to CFTALK
When you try to compare something, you need to compare like data types.
This may be why your database is never finding that date in there already.
Try something like this:
SELECT count(dateofpayment) AS rownum
FROM table
WHERE dateofpayment = #CreateODBCDate(form.dateofpayment)#
Furthermore, if you have a variables.rownum defined for whatever reason, I
believe CF will use that first, so don't do this:
<cfif rownum gte 1> <!---(which could be equivalent to variables.rownum)
--->
Do this:
<cfif myquery.rownum GTE 1>
And in fact because Count() guarantees to return an integer >= 0, to be
more efficient do this:
<cfif myquery.rownum>
<!--- 1 or more records found, so date already exists --->
Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Mike
Sent: Thursday, June 13, 2002 5:42 AM
To: [EMAIL PROTECTED]
Subject: [CFTALKTor] Check Existing Date in Database
Hello All,
I am having a little trouble checking for an existing date. I have a form
that passes a date from calendar that I am using. The calendar outputs
the date as follows 6/13/2002.
So I have a few fields that I insert into the database along with that
date.
There can only be one record per day. I try to do a row count in the
database before my insert statement to check if there is a row with that
date value but I keep getting 0
The field that is passed from the form is dateofpayment and the field in
the Access database is also dateofpayment
So I do
select count(dateofpayment) as rownum form table where dateofpayment =
#form.dateofpayment#
I have manually entered the data in the table so there is already that
date it should give me a record count of greater than one.
So I attempt to do a
<cfif rownum gte 1>
Go back to change the date
</cfif>
But this is not working. Does anyone have a better way to see if the date
already exists with Access or can tell where my logic is flawed?
Thanks in Advance
Mike
-
You are subscribed to the CFUGToronto CFTALK ListSRV.
This message has been posted by: [EMAIL PROTECTED]
To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/
Manager: Kevin Towes ([EMAIL PROTECTED]) http://www.CFUGToronto.org/
This System has been donated by Infopreneur, Inc.
(http://www.infopreneur.net)