hello,
i have a problem with two combobox when i want to add new record:
i have 3 table
product (id_prdt,....., idcat,idsup )
category_prodcut(idCatPrdt,.....)
supplier(id_sup,......)
i have a form contain all the information for the product and two combobox one for supplier and the other for categoryProduct.
this is the code:
Try
CN.Open()
cmd5.Connection = CN
Dim dr5 As OleDbDataReader
cmd5.CommandText = "insert into Produits values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & DateTimePicker1.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "')"
dr5 = cmd5.ExecuteReader
MsgBox("Enregistré avec succée") CN.Close()
Catch ex As Exception
End Try
in the form load i fill the combo of category_prodcut;
Try
Dim dr1 As OleDbDataReader
CN.Open()
cmd1.Connection = CN
cmd1.CommandText = "select * from Categories"
dr1 = cmd.ExecuteReader
Remplir_Liste_Produits()
While dr.Read
ComboBox2.Items.Add(dr.GetValue(1))
End While
CN.Close()
Catch ex As Exception
End Try
<pre lang="vb">
The problem when i try to use code to fill the second combobox i didn't know no error and no result:
Note: no link direct between the two table category product and supplier.
this the code of the form load:
Private Sub Ajouter_Produit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim dr As OleDbDataReader
CN.Open()
cmd.Connection = CN
cmd.CommandText = "select * from Categories "
dr = cmd.ExecuteReader
Remplir_Liste_Produits()
While dr.Read
ComboBox1.Items.Add(dr.GetValue(0).ToString)
End While
CN.Close()
Catch ex As Exception
End Try
Try
Dim dr1 As OleDbDataReader
CN.Open()
cmd1.Connection = CN
cmd1.CommandText = "select * from Fournisseurs "
dr1 = cmd.ExecuteReader
Remplir_Liste_Produits()
While dr1.Read
ComboBox2.Items.Add(dr1.GetValue(1))
End While
CN.Close()
Catch ex As Exception
End Try
End Sub
Thank you for help