If MaCommande.ExecuteScalar <> 1 then Dim InsertUser as new SqlCommand "INSERT INTO.....................",Maconnexion ELSE messagebox.Show("ERREUR............")
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionMaConnexion.Open() Dim CmdVerif As New SqlCommand("SELECT nom, prenom FROM ENTITE Where nom='" & Trim(txtNom.Text) & "' AND prenom='" & Trim(txtPrenom.Text) & "'", MaConnexion) If CmdVerif.ExecuteScalar <> 0 Then 'c'est que l'utilisateur existe déjà Else 'il n'existe pas End If MaConnexion.Close()
MaConnexion.Open() Dim CmdVerif As New SqlCommand("SELECT nom, prenom FROM ENTITE Where nom='" & Trim(txtNom.Text) & "' AND prenom='" & Trim(txtPrenom.Text) & "'", MaConnexion) Dim varID As String = CmdVerif.ExecuteScalar().ToString If varID <> "0" Then MaConnexion.Close() MessageBox.Show("Attention, cet utilisateur " & txtPrenom.Text & " " & txtNom.Text & ", existe déjà ! Modifier son nom ou prénom (ex : " & txtNom.Text & "2)") Else
If CmdVerif.ExecuteNonQuery("INSERT ....") = 0 Then // Aucune ligne insérée MessageBox.Show("...") End If