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
| Private Sub CbxRsFourNvCmd_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CbxRsFourNvCmd.SelectedIndexChanged
'pour le textbox
Try
Dim con3 As New OleDbConnection
con3.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MaBdd.accdb")
Dim cmd2 As New OleDbCommand
cmd2.CommandType = System.Data.CommandType.Text
cmd2.CommandText = "SELECT NumFournisseur From Fournisseur Where RaisonSocialeFour = '" & CbxRsFourNvCmd.Text & "' ;"
cmd2.Connection = con3
con3.Open()
Dim s As String = cmd2.ExecuteScalar.ToString
TxtBxNumFourNvCmd.Text = s
con3.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'Et pour le combobox après quelques recherche j'ai fait ça :
Try
Dim con4 As New OleDbConnection
con4.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MaBdd.accdb")
Dim cmd3 As New OleDbCommand
Dim lire As OleDbDataReader
cmd3.CommandType = System.Data.CommandType.Text
cmd3.CommandText = "SELECT NomProduit FROM Produit inner join Fournisseur on Produit.NumFournisseur = Fournisseur.NumFourisseur where RaisonSocialeFour = '" & CbxRsFourNvCmd.Text & "' ;"
cmd3.Connection = con4
con4.Open()
lire = cmd3.ExecuteReader
Do While lire.Read
CBxProdNvCmd.Items.Add(lire("NomProduit"))
Loop
lire.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End sub |
Partager