I am trying to create the code which Should not allow duplicates in the column 'Empid'.
What is the best way to prevent duplicates entries?
Can any one modify my insert code mentioned below so as to verify the entry and then if no duplicate it should insert.
My Insert code (VB.net and MYSQL):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cmd.Connection = cn
Dim sqlQuery As String = "INSERT INTO login (empid,password) VALUES('" & txtCreateempid.Text & "','" & txtCreatepassword.Text & "')"
With cmd
.CommandText = sqlQuery
.Connection = cn
.ExecuteNonQuery()
End With
MsgBox("Created New User")
txtCreateempid.Text = ""
txtCreatepassword.Text = ""
End Sub
What is the best way to prevent duplicates entries?
Can any one modify my insert code mentioned below so as to verify the entry and then if no duplicate it should insert.
My Insert code (VB.net and MYSQL):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cmd.Connection = cn
Dim sqlQuery As String = "INSERT INTO login (empid,password) VALUES('" & txtCreateempid.Text & "','" & txtCreatepassword.Text & "')"
With cmd
.CommandText = sqlQuery
.Connection = cn
.ExecuteNonQuery()
End With
MsgBox("Created New User")
txtCreateempid.Text = ""
txtCreatepassword.Text = ""
End Sub