Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21273

show message box That This Record already Exit in database ( no use Primary Key )

$
0
0
Hello,
i have a problem that when i insert a record duplicate not show message box how can this

code here in form

Private Sub Command1_Click()
If text1 = "" Then
MsgBox "Type Class ID.", vbOKOnly + vbExclamation, "Class Number Empty Error"
text1.SetFocus
If text2 = "" Then
MsgBox "Type Class Number.", vbOKOnly + vbExclamation, "Class Number Empty Error"
text2.SetFocus
ElseIf text3 = "" Then
MsgBox "Type Class Name.", vbOKOnly + vbExclamation, "Class Name Empty Error"
text3.SetFocus
Else

Set rs = con.Execute("SELECT * FROM classnamen")
If rs.RecordCount = 0 Then

con.Execute ("INSERT INTO classnamen VALUES('" & txtclassid.Text & "', '" & text2.Text & "', '" & text3.Text & "')")
MsgBox "New Class Name successfully added.", vbOKOnly + vbInformation, "Success"
Unload Me
Else
Set rs = con.Execute("SELECT * FROM classnamen")
With rs
recfound = True
UserID = !UserID
username = !username
Password = !UPassword
End With

If username = text2 Then
MsgBox "already Exit.", vbOKOnly + vbExclamation, "User Name"
txtusername.Text = ""
txtusername.SetFocus
ElseIf Password = text3 Then
MsgBox "already Exit.", vbOKOnly + vbExclamation, "Password"
txtPassword.Text = ""
txtPassword.SetFocus
Else

con.Execute ("INSERT INTO classnamen VALUES('" & txtclassid.Text & "', '" & text2.Text & "', '" & text3.Text & "')")
MsgBox "New Class Name successfully added.", vbOKOnly + vbInformation, "Success"
Unload Me
End If
End If
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Activate()
Call konek
End Sub

but when i insert duplicate record no error show
how this posibal

Viewing all articles
Browse latest Browse all 21273

Trending Articles



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