hello.. i have problem load two data from different table and column.. for example, each data from product table into product combobox and brand table to brand combobox..i succussfully load data to combobox but got multiple same data into combobox..

Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Application.StartupPath & "\mydatabase.mdb;Jet OLEDB:Database Password=admin;")

        Dim cmd As OleDbCommand = New OleDbCommand("SELECT product.productN,brand.brandN FROM product, brand", conn)

        conn.Open()

        Dim sdr As OleDbDataReader = cmd.ExecuteReader

        While sdr.Read()

            product.Items.Add(sdr.Item("productN").ToString)
            brand.Items.Add(sdr.Item("brandN").ToString)



        End While

        conn.Close()

    End Sub

Edited 3 Years Ago by arezz09

Attachments 3.jpg 28.92 KB 2.jpg 8.59 KB 4.jpg 51.75 KB 1.jpg 9.96 KB

make proper use of distinct in your select statement.

try this(i am not sure)

"SELECT distinct product.productN,brand.brandN FROM product, brand

this happens due to two reasons
1.You haven't put a primary key
2.put a two condition seperately for two comboboxes

Edited 3 Years Ago by Dili1234: still witing

Try this one dude:

Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & Application.StartupPath & "\mydatabase.mdb;Jet OLEDB:Database Password=admin;")
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT product.productN,brand.brandN FROM product FULL JOIN brand ON product.productN = brand.brandN", conn)
        conn.Open()
        Dim sdr As OleDbDataReader = cmd.ExecuteReader
        While sdr.Read()
              If Not sdr("ProductN").ToString = String.Empty Then product.Items.Add(sdr.Item("productN").ToString)
              If Not sdr("brandN").ToString = String.Empty Then brand.Items.Add(sdr.Item("brandN").ToString)
        End While
        conn.Close()
    End Sub
This article has been dead for over six months. Start a new discussion instead.