bonjour les pros,
Comment interdire les doublons sur ma base ?
J'ai fait une petite appli, mais j'ai un problème avec des doublons.
voici mon code vb d'insertion dans la base, je veux interdire les doublons sur le numéro de police.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 Private Sub BT_Valider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_Valider.Click
        If (Text_Numero_Police.Text = "") Then
            MsgBox("Veuillez Chaissir le Numero de Police SVP", MsgBoxStyle.Information + MsgBoxStyle.OkCancel, "Information")
        ElseIf Txt_Nom_Prenom_Client.Text <> "" And Txt_Type_Compteur.Text <> "" And Txt_Type_Branchement.Text <> "" And Text_Numero_Police.Text <> "" And Text_index_compte.Text <> "" And Text_Contact_Client.Text <> "" And Txt_Contact_Technicien.Text <> "" Then
            Dim Requete As String = "INSERT INTO Client VALUES('" + Txt_Nom_Prenom_Client.Text.ToString() + "','" + Txt_Type_Compteur.Text.ToString() + "','" + Txt_Type_Branchement.Text.ToString() + "', '" + Text_Numero_Compteur.Text.ToString() + "','" + Text_Numero_Police.Text.ToString() + "','" + Text_index_compte.Text.ToString() + "','" + CB_Nom_Prenom_Technicien.Text.ToString() + "','" + Text_Contact_Client.Text.ToString() + "','" + Txt_Contact_Technicien.Text.ToString() + "','" + dta.Text.ToString() + "')"
            Try
                Connexion.Open()
                Dim commande As New SqlCommand(Requete, Connexion)
                commande.ExecuteNonQuery()
                If MsgBox("Enregistrement de Branchement Réussi!!! Voulez-vous continuer?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Information") = MsgBoxResult.Yes Then
                    Txt_Nom_Prenom_Client.Text = ""
                    Txt_Type_Compteur.Text = ""
                    Txt_Type_Branchement.Text = ""
                    Text_Numero_Compteur.Text = ""
                    Text_Numero_Police.Text = ""
                    Text_index_compte.Text = ""
                    Text_Contact_Client.Text = ""
                    CB_Nom_Prenom_Technicien.Text = ""
                    Txt_Contact_Technicien.Text = ""
                    dta.Text = ""
                Else
                    Me.Close()
                    Txt_Nom_Prenom_Client.Text = ""
                    Txt_Type_Compteur.Text = ""
                    Txt_Type_Branchement.Text = ""
                    Text_Numero_Compteur.Text = ""
                    Text_Numero_Police.Text = ""
                    Text_index_compte.Text = ""
                    Text_Contact_Client.Text = ""
                    CB_Nom_Prenom_Technicien.Text = ""
                    Txt_Contact_Technicien.Text = ""
                    dta.Text = ""
 
                End If
                commande.Dispose()
                Connexion.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub