Quantcast
Viewing all articles
Browse latest Browse all 27061

VS 2008 How to prevent duplicate entries in Vb.net using Mysql database

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

Viewing all articles
Browse latest Browse all 27061

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>