Trap Duplicate Record in Database using Visual Basic 6

Download
Download is available until [expire_date]
  • Version
  • Download 288
  • File Size 38.71 KB
  • File Count 1
  • Create Date April 28, 2016
  • Last Updated April 28, 2016

Trap Duplicate Record in Database using Visual Basic 6

Trap Duplicate Record in Database using Visual Basic 6

Trapping of duplicate record simply means to prevent same record to be saved in your database. This is the program that demonstrates how to do that.

It is very necessary to trap duplicate records in the database for the reason that it will confuse the user of the system which is the exact one and which is not and those redundant records consumes space in your database that will cause your system to slow down.

You can actually trap the duplicate record from your database itself by setting the primary key or you can put that into codes just like this program.

You are free to email us for any questions and suggestions.

Thank you and Happy Programming!

Source code:

Sub AddUser(Username As String)

If rs.State = adStateOpen Then rs.Close
    sql = "Select * From Accounts Where username='" & Username & "'"
    rs.Open sql, conn
        If rs.RecordCount >= 1 Then
            MsgBox "Duplicate username found.Please enter another username.", vbCritical, ""
            Exit Sub
        End If
    With rs
        .AddNew
        !Username = Username
        
        .Update
        End With
        MsgBox "Record(s) Updated", vbInformation, ""
End Sub
, , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.