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
|
Dim resultat As String
Dim cmd As New MySqlCommand
Dim da As New MySqlDataAdapter
Dim dt As New DataTable
Try
'début du test, si les zonnes de text sont vide, faire
If TextBoxTitreLivre.Text = "" Or TextBoxNomAuteur.Text = "" Or TextBoxNumGenre.Text = "" Then
MsgBox("case vide !!!", MsgBoxStyle.Information)
Else
'ouverture de la connexion
connexion.Open()
'contenir les données
With cmd
.Connection = connexion
.CommandText = "select titrelivre, auteurlivre from bibliotheques where titrelivre='" & TextBoxTitreLivre.Text & "' and auteurlivre='" & TextBoxNomAuteur.Text & "'"
'éxecution
resultat = cmd.ExecuteNonQuery
' si l'indo existe déjà dans la base de données
If resultat = 0 Then
MsgBox("record exists", MsgBoxStyle.Information)
connexion.Close()
Else
ajout("insert into bibliotheques (titrelivre, genre, auteurlivre, dateEntre, numenregistrement, nbrpartie, infopublication, source, etagere, edition) values('" & TextBoxTitreLivre.Text.ToString & "', '" & TextBoxNumGenre.Text.ToString & "', '" & TextBoxNomAuteur.Text.ToString & "', '" & TextBoxDateEntree.Text.ToString & "', '" & TextBoxNumEnregistrement.Text.ToString & "', '" & TextBoxNbPartie.Text.ToString & "', '" & TextBoxInfoPublication.Text.ToString & "', '" & TextBoxSource.Text.ToString & "', '" & TextBoxEtagere.Text.ToString & "', '" & TextBoxEdition.Text.ToString & "')")
connexion.Close()
Me.Hide()
Form1.Show()
End If
End With
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub |
Partager