[RESOLVED] Display of more than one table in DGV
I am using a join query to display data in a DGV and it goes like this:
Code:
SELECT lnkVendorSpec.VendorSpecID,tblSupplyMaster.intSiTechID, tblSupplyMaster.strSupplierName
FROM ((lnkVendorSpec INNER JOIN
tblSupplyMaster ON tblSupplyMaster.intSiTechID = lnkVendorSpec.intSiTechSupplyID) INNER JOIN
tblItemMaster ON tblItemMaster.intSiTechID = lnkVendorSpec.intSiTechItemID)
WHERE (lnkVendorSpec.intSiTechItemID = ?)
There is no problem with the query and it completely fulfills it requirements. However, I have a fondness for using a double click event to select one of the rows in the display to do any of several things with the row selected. As can be seen in the query, data from two tables are contained in the SELECT command.
So what I want to do is double click on a row and in the double click event have a variable value equal to the value from lnkVendorSpec.VendorSpecID (which is an integer). I have several methods that I have used to do this in a DGV consisting of data from a single table in the SELECT, but none of them work for this. Can someone explain to me how one would obtain values from a DGV containing columns from more than one table?
Re: Display of more than one table in DGV
Having a dgv filled with data from multiple table really has no affect on retrieving the value of a cell. It's pretty straight forward.
Code:
Private Sub DataGridView1_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Dim varString As String = Me.DataGridView1.CurrentRow.Cells("ReserveName").Value.ToString
MessageBox.Show(varString)
End Sub
Re: Display of more than one table in DGV
Wes,
Well crap. That was one of the methods I attempted to use. However, I must have had something wrong in the code, because it went wrong several times, but when I used it the way you had it (but changed the code to fit my variable, etc.) it works. I really hate it when I do that, but thanks for the help and setting me on the right path, even though I do not know where it was that I went wrong. I wonder if maybe it was the fact that I put CInt() around the whole thing that caused me to mess it up? I will have to check that.