Question regarding datagrids in vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Velocis
    New Member
    • Jun 2010
    • 2

    #1

    Question regarding datagrids in vb6

    I have 2 separate tables that need to be joined together. I'm trying to display certain fields from both tables by joining them with a matching field(same values but different column name) The user enters their employee id, then I need to return the other field values associated with that specific id# in a datagrid.

    So far I'm able to return the other field values from one of my tables according to the id# entered

    Code:
    'my connection stuff is here
    rs.open "select swpNum, swpInfo, swpType from tblSwipes WHERE (swpNum='"& sNum &"') and swpType=1 order by etc...
    set datagrid.datasource=rs
    I'm ok up to here..The datagrid displays the 3 fields associated with the # the user enters. But I'm having trouble when I try to join tblSwipes with tblEmp to get fields returned from that table as well. Here's what I have for my new query

    Code:
    rs.open "SELECT tblEmp.lastName,tblEmp.firstName,  tblEmp.payNum, tblSwipes.swpNum, tblSwipes.swpType  
    FROM tblEmp INNER JOIN tblSwipes 
    ON tblEmp.payNum=tblSwipes.swpNum 
    WHERE (swpNum='"& sNum &"') and swpType=1 
    order by etc...
    
    set datagrid2.datasource =rs
    Nothing is shown in the datagrid using this query..any tips or suggestions on another way of doing this would be greatly appreciated.
  • irfanafzal
    New Member
    • May 2010
    • 12

    #2
    Originally posted by Velocis
    I have 2 separate tables that need to be joined together. I'm trying to display certain fields from both tables by joining them with a matching field(same values but different column name) The user enters their employee id, then I need to return the other field values associated with that specific id# in a datagrid.

    So far I'm able to return the other field values from one of my tables according to the id# entered

    Code:
    'my connection stuff is here
    rs.open "select swpNum, swpInfo, swpType from tblSwipes WHERE (swpNum='"& sNum &"') and swpType=1 order by etc...
    set datagrid.datasource=rs
    I'm ok up to here..The datagrid displays the 3 fields associated with the # the user enters. But I'm having trouble when I try to join tblSwipes with tblEmp to get fields returned from that table as well. Here's what I have for my new query

    Code:
    rs.open "SELECT tblEmp.lastName,tblEmp.firstName,  tblEmp.payNum, tblSwipes.swpNum, tblSwipes.swpType  
    FROM tblEmp INNER JOIN tblSwipes 
    ON tblEmp.payNum=tblSwipes.swpNum 
    WHERE (swpNum='"& sNum &"') and swpType=1 
    order by etc...
    
    set datagrid2.datasource =rs
    Nothing is shown in the datagrid using this query..any tips or suggestions on another way of doing this would be greatly appreciated.
    which database you are using Access or sql server if you r using Access then
    try this before opening recordset
    Rs.CursorLocati on = adUseClient

    Comment

    • Velocis
      New Member
      • Jun 2010
      • 2

      #3
      i'm using sql server. the problem was with my inner join clause. i just got rid of that and it worked. thanks for the response : )

      Comment

      Working...