Like this:

<cftransaction>

<cfquery datasource="DSN" name="CHKuser">
    SELECT * FROM WHERE UserName = '#UserName#'
</cfquery>


<cfif not (CHKuser.Reocrdcount)>
<cfquery datasource="DSN" name="AddUser">

    INSERT INTO Users
    (UserName, RealName,  Email)
    VALUES     ('#UserName#','#RealName#','#Email#')

</cfquery>

<cfelse>

User name exists
<cfabort>

</cfif>


</cftransaction>

but I still like the


<cftry><cfcatch type=database>  :-)


~Justin MacCarthy


----- Original Message -----
From: "Jeremy Toevs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 29, 2000 5:01 PM
Subject: RE: UserAction.cfm


> How would that query look?
>
> >>> Kelly Matthews <[EMAIL PROTECTED]> 08/29/00 08:43AM >>>
> What i normally do is FIRST I RUN a QUERY against the database
> seeing if the USERNAME that was passed is equal to any username in the
> database. Then i do a <CFIF query.recordcount GT "1">
> and show a message that the username is taken and then a <CFELSE>
> that does the insert. That way if the query comes back with at least
> ONE record you know the user id is taken if it comes back with ZERO
> you do the insert.
> Kelly
>
> Stay current with what's happening on AirportNet. Subscribe to our
> Announcement list today: http://www.airportnet.org/email.htm
>
> ---------------------------------------
> Kelly Matthews
> Internet Development Coordinator
> AAAE
> 703.578.2509
> [EMAIL PROTECTED]
> http://www.airportnet.org
> ---------------------------------------
>
> > -----Original Message-----
> > From: Jeremy Toevs [SMTP:[EMAIL PROTECTED]]
> > Sent: Tuesday, August 29, 2000 11:49 AM
> > To: <
> > Subject: UserAction.cfm
> >
> > When you have a "No Duplicates" field in the database and a duplicate is
> > entered, CF returns somewhat of a weird error message. How do you get it
> > to return an error message saying "This UserName is already in use,
choose
> > another." UserName being the "No Duplicates" field. Here is my action
cfm:
> >
> > *********************************************************
> >
> > <cfquery datasource="DSN" name="AddUser">
> > INSERT INTO Users (UserName, RealName, Email)
> > VALUES ('#UserName#','#RealName#','#Email#')
> > </cfquery>
> >
> > *********************************************************
> >
> > Thanks in advance,
> >
> > Jeremy
> >
>
> --------------------------------------------------------------------------
> > ----
> > Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> > 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.mail-archive.com/cf-talk@houseoffusion.com/
> 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.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar
>
>

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
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.

Reply via email to