CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Checking for user names in Database before registration

Print topic Send  topic

Author Message
mas7357

Posts: 29
Posted: 08/28/2007, 1:39 AM

Can anyone help me with this problem

I have a registration page (record) where administrators of my DB register members first and last name together with a user name and password and other info. I would like to check on submission of the registration form whether their full name (first and last name) are already in the database before committing the information as I don't want people to be registered more than once in the database I have a very simple line of code currently that checks for the presence of the first name and last name separately in the DB which is OK but doesn't really work for obvious reasons

If (CCDLookup("count(*)", "tblSwimmerDetailsConfidential","Last_Name= " & "'" & Last & "'", DBConnection1)) >0 and (CCDLookup("count(*)", "tblSwimmerDetailsConfidential","First_Name= " & "'" & First & "'", DBConnection1)) >0 Then tblSwimmerDetailsConfiden3.Errors.Adderror("Swimmer Already in DataBase-Search to be Sure! ")

Can anyone help me with the CCDlookup syntax- Please help me complete this free :-)project for my local swimming club
_________________
MikeS
View profile  Send private message
wkempees
Posted: 08/28/2007, 3:30 AM

The easiest way to accomplish this would be to
create a unique key (constraint) on the table (Last_Name, First_Name)
That way upon insert the database will deny insertion leaving you to catch
the error().

The other way (your example) just combine the Where of the CCDLookup().
Something like this,

  
 If (CCDLookup("count(*)", "tblSwimmerDetailsConfidential","Last_Name= " &   
"'" &  
Last & "'" AND "First_Name= " & "'" & First & "'",  
DBConnection1)) >0 Then tblSwimmerDetailsConfiden3.Errors.Adderror("Swimmer  
Already in DataBase-Search to be Sure! ")  

Please report back with the database type you are using as I do not like
above syntax.
Something is off, where are you useing this code? Which Event?

Walter

mas7357

Posts: 29
Posted: 08/28/2007, 3:58 AM

Thanks for the speedy reply Walter- I am a novice at this so your first suggestion is a little over my head- I will do some homework with Access (my DB) to try and understand what you mean.

I have the current code in the before execute insert event - with the following line after it

tblSwimmerDetailsConfiden3.DataSource.CmdExecution = false

I am sure it should go in the on validate event but I didn't work there!


_________________
MikeS
View profile  Send private message
DonB
Posted: 08/30/2007, 5:08 AM

You can't set CmdExecution that early in the 'chain' of events because it's
not initialiized until the insert starts (validate comes right before that).
In the validate event, the correct thing to do is return 'false' from the
function and/or add an error message (string) to the Error property of the
form that's doing the validation. Either of these will abort the form
processing so that the insert operation is never begun.

--
DonB

http://ccswiki.gotodon.net


"mas7357" <mas7357@forum.codecharge> wrote in message
news:646d3ffb84448c@news.codecharge.com...
> Thanks for the speedy reply Walter- I am a novice at this so your first
> suggestion is a little over my head- I will do some homework with Access
(my DB)
> to try and understand what you mean.
>
> I have the current code in the before execute insert event - with the
following
> line after it
>
> tblSwimmerDetailsConfiden3.DataSource.CmdExecution = false
>
> I am sure it should go in the on validate event but I didn't work there!
>
>
> _________________
> MikeS
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.