1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\samir\Desktop\BD_Eleve.accdb")
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If (String.IsNullOrWhiteSpace(TextBox1.Text) AndAlso String.IsNullOrWhiteSpace(TextBox2.Text)) Then
MessageBox.Show("il faut remplir tout les champs")
Return
End If
'etape de declaration de la commande d'insertion
Dim cmd As New OleDbCommand("insert into note1 (NomEtPrenom,Adresse,DateDeNaissance) values ('" & TextBox1.Text & "','" & TextBox2.Text & "',#" & DateTimePicker1.Value.ToString("yyyy / MM / dd") & "#,)")
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
End Sub |
Partager