Duplicate records!

Results 1 to 2 of 2

Thread: Duplicate records!

  1. #1
    Join Date
    Dec 1969

    Default Duplicate records!

    Hi,<BR><BR>I want to check the duplicate name. if it exist then display a message or add to the database if it is a new name. I know it is very simple but I can&#039t get this.<BR><BR>My code is:<BR><BR>&#039there are text boxes to enter the person&#039s first name, middle Initial and last name.<BR><BR>Dim conn, rs<BR>Set conn= Server.CreateObject("ADODB.Connection")<BR>conn.Op en "myDSN"<BR>Set rs=Server.CreateObject("ADODB.Recordset")<BR>rs.Op en "Users", conn, adOpenDynamic, adLockOptimistic, adCmdTable<BR><BR><BR>Do While rs.EOF<BR>If ((rs("Firstname")= Request.Form("Firstname"))AND (rs("Middleinitial")= Request.Form("Middleinitial")) AND (rs("Lastname")= Request.Form("Lastname"))) Then<BR><BR>Response.Write "Sorry, this name is already exist. please enter another name thankyou."<BR>Else<BR><BR>rs.AddNew<BR>rs("Firstna me")= Request.Form("Firstname")<BR>rs("Middleinitial")= Request.Form("Middleinitial")<BR>rs("Lastname")= Request.Form("Lastname") <BR><BR>End If<BR>rs.MoveNext<BR>loop<BR><BR>conn.close<BR>set conn= nothing<BR><BR>rs.close<BR>set rs= nothing<BR><BR>It is entering the duplicate name. Can somebody help me or give me any suggestion?<BR><BR>Thanks in advance.<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Duplicate records!

    Dim UserCount<BR><BR>Select Users.* From Users Where Firstname=&#039" & Request.form("Firstname") & "&#039 and Middleinitial=&#039" & Request.Form("Middleinitial") & "&#039 And Lastname=&#039" & Request.Form("Lastname") & "&#039;"<BR><BR>rs.Open sql, Conn, 3, 3<BR><BR>If rs.RecordCount &#062; 0 Then<BR><BR>Response.Write "Sorry, this name is already exist. please enter another name thankyou."<BR><BR>Else<BR><BR>rs.AddNew<BR>rs("Fir stname")= Request.Form("Firstname")<BR>rs("Middleinitial")= Request.Form("Middleinitial")<BR>rs("Lastname")= Request.Form("Lastname") <BR>rs.Update<BR>End If<BR><BR>Close all your connections<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