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

Recommended Answers

All 4 Replies

make proper use of distinct in your select statement.

try this(i am not sure)

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

still not work dude..nothing happen

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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.