No Double Data in Database

Results 1 to 2 of 2

Thread: No Double Data in Database

  1. #1
    Mellanie Guest

    Default No Double Data in Database

    I have managed to make a page in which you can insert your own data.<BR>Only I want to prevent from getting the same username and emailadresses in my database.<BR><BR>Which code should I use??<BR><BR>Thank you very much!<BR><BR>Mellanie

  2. #2
    Nils Bilhorn Guest

    Default Prevent duplicates

    You could define a unique constraint for the column(s)<BR>e.g.<BR> alter table t add constraint uniqueName unique(username)<BR><BR>or whatever your table and column(s) are named. On top of that you can add an check in your ASP page that does a <BR><BR> set rs = db.execute("select 1 from t where username = &#039;" & _<BR> request.form("username") & "&#039;")<BR> if not rs.eof then<BR> response.write "Sorry dude, choose another name"<BR> else<BR> &#039;go ahead and insert data<BR> end if<BR><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