Checking Database Duplicates

Results 1 to 2 of 2

Thread: Checking Database Duplicates

  1. #1
    W. Glenn Campbell Guest

    Default Checking Database Duplicates

    I Have a faily simple question for the advances database programmer. Here is the problem that I am running into.<BR><BR>I am using an access database to hold user information (i.e. usernames, passwords, etc.) for an online forum. I am able to get all of the tables to update just fine, and everything seems to ne working correctly, but the problem that I am running into is that I am not sure what script I need to write to check to see if a username in the database is already being used. If the UserID is being used, I want to write do a Response.Write command telling the username is already in use, and that they need to select another one. If the UserID is not found in that database, I want it to do the next SQL command which is the INSERT INTO statement. Please help.<BR><BR><BR>W. Glenn Campbell

  2. #2
    Join Date
    Dec 1969

    Default help is here!

    aaah yes, checking the, i have not done this repeatedly...i will use a dsn name of "login", a table name of "login" and fields "userid" and "password"...but here it goes:<BR><BR>&#060;%<BR>userid=request.form("useri d")<BR>password=request.form("password")<BR>set dbcn=server.createobject("adodb.connection")<BR>db "dsn=login"<BR>sql="select count(userid) as acount from login where userid=&#039" & userid & "&#039"<BR>set rstemp=dbcn.execute(sql)<BR>acount=rstemp("acount" )<BR>if acount=0 then<BR>mysql="insert into login (userid,password) values (&#039" & userid & "&#039,&#039" & password & "&#039)"<BR>dbcn.execute(mysql)<BR>else<BR>respons e.write "Sorry, the username is taken!"<BR>end if<BR>dbcn.close<BR>set dbcn=nothing<BR>%&#062;<BR><BR>hope this helps!!<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts