Results 1 to 3 of 3

Thread: Datagrid to display data from two tables

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    8

    Datagrid to display data from two tables

    Hi,

    I am trying to display data from two tables in the one datagrid using an ado data control. The first table is expenses and the second is rates and they are joined by rateid. The trouble is I wasnt to show expenses for just one employee..

    Having major difficulty. Any help would be appreciated.

  2. #2
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: Datagrid to display data from two tables

    The best way to achive what you are after is to use the MSHFlexGrid control and implementing a Shape command

  3. #3
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    Bahrain
    Posts
    306

    Re: Datagrid to display data from two tables

    Hi,

    In this case you have to establish SQL Query and then pass the SQL Query into the ADODC Data Control.

    Here's a simple code it might help you. But before that this code it return the employee how much contacts that he / she have where the employee name is located in the Combo Box.

    VB Code:
    1. 'The query is response on the Click Event.
    2. Private Sub Combo1_Click()
    3.  
    4. SQL = "Select EmployeesData.[FirstName], EmployeesData.[SecondName], Contacts.[Mobile]"
    5. SQL = SQL & "From [EmployeesData], [Contacts]"
    6. SQL = SQL & "Where EmployeesData.[EmpID] = Contacts.[EmpID]"
    7. SQL = SQL & "And EmployeesData.[FirstName]='" & Combo1.Text & "';"
    8.  
    9. Adodc1.RecordSource = SQL                   ' Execute your query
    10. Set DataGrid1.DataSource = Adodc1    ' Bind to the data control

    Hope this will help you.

    Best Regards,
    Habibalby
    Current Project: General Employees Database (Employees Information) & (Training Details).

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