hello guys i need help how can u get the data in to two tables in one form. This code works but the problem is like in combobox2.text the data is display twice and also in inEmployee.text the data is display 4 time both are combobox so when u click the combobox u can see that the data is display twice or 4 times.....
i need help please


Dim sqlquery = "SELECT * FROM facilitydata, customerdata, employeedata"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery

'start query
myAdapter.SelectCommand = myCommand

Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()

Try
While myData.Read

Try

ComboBox2.Text = "Select"
ComboBox3.Text = "None"
Me.ComboBox2.Items.Add(myData.Item("facname"))
Me.ComboBox3.Items.Add(myData.Item("amenity"))
Me.Textbox1.Items.Add(myData.Item("custname"))
Me.inEmployee.Items.Add(myData.Item("empname"))


Catch ex As Exception
MsgBox("!ERROR!")
End Try

End While

Your SELECT, as is written, is called a cross join. This will mean that all the rows of facilitada are merged to each row in customer data, then the resulting set is merged to each row in employee data.

If you have 3 rows in the first table, 2 on the second one and 4 in the 3rd the result will be 24 rows.

Maybe this is not what you expect.

Try to change the SELECT using some INNER JOIN clause defining how to relate the tables.

Hope this helps

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.