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
|
Public Class add_contatct
Dim Host As New MySqlConnection 'pour la connexion a la base de donnée
Dim req As MySqlDataAdapter 'objet MySqlDataAdapter qui par sa propriété Fill charge le DataSet
Public da1 As MySqlDataAdapter 'pour mettre a jour la BASE et DATASOURCE
Dim dst1, dst As New DataSet
' Dim MyNewRow As New DataRow
----------------------------------------------------------------------
Private Sub Butadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Butadd.Click
Try
Dim MyNewRow As DataRow = dst.Tables("person").NewRow
MyNewRow("First_Name") = Me.txtfirstname.Text
MyNewRow("Last_Name") = Me.txtlastname.Text
MyNewRow("Fone_Num") = Me.txtfonenum.Text
MyNewRow("Country") = Me.txtcountry.Text
dst.Tables("person").Rows.Add(MyNewRow)
Dim MyCommBuild As New MySqlCommandBuilder(da1)
da1.Update(dst, "person")
MsgBox("Nouvel enregistrement ajouté avec succés", MsgBoxStyle.Information)
clean()
Catch err As Exception
MsgBox(err.Message, MsgBoxStyle.Exclamation, "person")
dst = New DataSet
da1 = New MySqlDataAdapter("SELECT * FROM person", Host)
da1.Fill(dst, "person")
' ' DataGrid1.DataSource = dst.Tables("contact")
' 'MsgBox("OK")
Exit Sub
End Try |
Partager