|
-
Mar 28th, 2013, 06:17 AM
#1
Thread Starter
Registered User
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|