daJoin = New OleDbDataAdapter("SELECT Company.CompanyID, Company.CompanyName, Product.ProductID, Product.ProductDesc, Product.RawMatDesc FROM (Product " &
"INNER JOIN Company ON Company.CompanyID=Product.CompanyID)", con)
daJoin.Fill(dsJoin, "Product")
con.Close()
dgvProdView.DataSource = dsJoin.Tables("Product")
What you are seeing above this is my code that will combine datatable Product and Company into 1 datagridview.
The next thing I want to do is to get the exact displayed data using the datagridview event cellmouseclick.
Private Sub btnSelProd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelProd.Click
indexProd = dgvProdView.CurrentRow.Index
txtProdDesc.Text = ds.Tables("Product").Rows(indexProd).Item("ProductDesc")
txtRawMatDesc.Text = ds.Tables("Product").Rows(indexProd).Item("RawMatDesc")
End Sub
The codes there worked perfectly fine for me. it transfers the exact display into my datatable but when I added another statement.
Private Sub btnSelProd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelProd.Click
indexProd = dgvProdView.CurrentRow.Index
txtCompName.Text = ds.Tables("Company").Rows(indexProd).Item("CompanyName")
txtProdDesc.Text = ds.Tables("Product").Rows(indexProd).Item("ProductDesc")
txtRawMatDesc.Text = ds.Tables("Product").Rows(indexProd).Item("RawMatDesc")
End Sub
When I tried to run it and clicked the datagridview, it did'not gave me the displayed companyname but rather it gave me a Companyname that was not even in the joined table display.
Need help mates.