Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Visual Basic 6 - Grids - Manual Populating

  • 19-03-2007 7:02am
    #1
    Registered Users, Registered Users 2 Posts: 695 ✭✭✭


    Ok, so here's my problem.

    I'm trying to populate a grid with data from two tables, and my SQL ain't too sharp (and I'm not sure this can be even pulled with SQL).

    Heres an example:
    Table1
    Name  -  Height  -  Class  -  Age  -  Suspended
    ---------------------------------------------
    Tom    |    6    | Science |  18   |  No  |
    Dick   |    7    | Science |  17   |  No  |
    Harry  |    4    |  Math   |  16   |  No  |
    Janet  |    4    |  Math   |  16   |  Yes |
    
    Table1
    Class  -  Room  -  Doors
    -----------------------
    Math    |   303    | 3  |
    Science |   301    | 4  |
    Blah    |   101    |  10 |
    Bleh    |   666    |  -3 |
    

    What I wanna pull is the [Name] and [Age] from Table1 if Suspended is not Yes. And I wanna take the [Room] and [Doors] from Table2, and put them nicely in a grid that would look something like this.
    Results!
    Name  -  Age  -  Room  -  Doors
    -------------------------------
    Tom    |   18   | 301  |  4   |
    Dick   |   17   | 301  |  4   |
    Harry  |   16   | 303  |  3   |
    

    The problem is, DataGrid and DBGrid objects don't let me manually add in stuff into them with code.

    FlexGrid will work but it is butt ugly and has no column headers.

    I'm trying to avoid using 3rd party components, as I'm not sure how lecturers might look on that. This is like the last part of a big project and its real frustrating that I didn't get to finish it tonight. Have run out of cigarettes so it's time to sleep and start fresh tomorrow.

    I've ages googling around, and not come up with much.


Comments

  • Registered Users, Registered Users 2 Posts: 695 ✭✭✭DaSilva


    Oh wow, it was an easy SQL statement, just couldn't figure it out last night for some reason.

    Here's what seems to work anyway.

    SELECT Table1.Name, Table1.Age, Table2.Room, Table2.Doors
    FROM Table1, Table2
    WHERE Table1.Suspended = 0 AND Table1.Class = Table2.Class

    SQL is kinda nice :)


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    gald you sorted it
    SQL is everywhere in the real world very handy to know
    just remember your sets from Leaving Cert maths


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    I seem to remember using the ListView control in Vb6 instead of databound controls. If I remember correctly it was because the databound controls never did what I wanted them too. Slightly OT but there ya go :)


Advertisement