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
| Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.Sql
Public Class Form1
Public Sub fonction_Ajouter(ByVal AjouterNew As String)
Dim Requete As String = "Insert into Tbl_Especes(Espece_ID) values ('" & AjouterNew & "')"
Dim Commande As New SqlCommand(Requete)
Try
Commande.ExecuteNonQuery()
Catch ex As System.Data.SqlClient.SqlException
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: cette ligne de code charge les données dans la table Database1DataSet.Tbl_Especes.
Vous pouvez la déplacer ou la supprimer selon vos besoins.'
Me.Tbl_EspecesTableAdapter.Fill(Me.Database1DataSet.Tbl_Especes)
End Sub
Private Sub BtnNew_Click(sender As Object, e As EventArgs) Handles BtnNew.Click
Dim AddNew As String
AddNew = InputBox("Veuillez saisir la nouvelle espèce :", "NOUVELLE ESPECE")
If AddNew <> "" Then
fonction_Ajouter(AddNew)
End If
End Sub
End Class |
Partager