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 36 37 38 39 40 41 42 43 44 45 46 47
| Dim maconnexion As New OleDb.OleDbConnection("provider=Microsoft.jet.OLEDB.4.0;Data source =..\basedonneeDVD.mdb;persist security info=false")
Dim maCommand As New OleDb.OleDbCommand()
Dim chainesql As String
Dim monDA As New OleDb.OleDbDataAdapter()
Dim numab As String
Private Sub dvd_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
maconnexion.Open()
chaineSql = "SELECT * FROM DVD, Preter, Abonne WHERE DVD.idDVD=Preter.idDVD And Preter.idAbonne=Abonne.idAbonne"
maCommand.CommandText = chaineSql
maCommand.Connection = maconnexion
monDA.SelectCommand = maCommand
monDA.Fill(datasetpret, "Liste des prets")
maDT = datasetpret.Tables("Liste des prets")
cbx_abonne.DataSource = maDT
cbx_abonne.DisplayMember = "nomAbonne"
cbx_titre.DataSource = maDT
cbx_titre.DisplayMember = "titreDVD"
Catch ex As Exception
MsgBox(ex.Message)
End Try
maconnexion.Close()
End Sub
Private Sub btn_valider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_valider.Click
If action = 1 Then
Try
OleDbConnectiondvd.Open()
numab = "select idAbonne from abonne where nomabonne=@NumAb"
Dim cmdSelectAbonnes As New OleDbCommand(numab, maconnexion)
cmdSelectAbonnes.Parameters.Add("@NumAb", SqlDbType.Int).Value = cbx_genre.SelectedValue
chaineSql = "insert into Preter (idAbonne, idDVD, datepret)values ('" & numab & "','" & cbx_titre.Text & "','" & cbx_date.Text & "')"
commandinsert.CommandText = chaineSql
commandinsert.Connection = OleDbConnectionpret
commandinsert.ExecuteNonQuery()
MsgBox("Pret enregistré")
Catch ex As Exception
MsgBox(ex.Message)
End Try
OleDbConnectionpret.Close()
End If
End Sub |
Partager