Results 1 to 3 of 3

Thread: [RESOLVED] Display of more than one table in DGV

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    705

    Resolved [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?

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,508

    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    705

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width