Results 1 to 9 of 9

Thread: Simple SQL query

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2003
    Posts
    253

    Simple SQL query

    Hi All,

    Select * from XYZ query will display result in this way:

    Filed1-----Field2-----Field3
    A----------A--------A
    B----------B--------B
    C----------C-------C

    What query will display the result in this way?

    Filed1-----A
    Filed2-----A
    Field3-----A

    Thanks

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Simple SQL query

    it will not display as you expect...if you want to display like that in vb you have to code it...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2003
    Posts
    253

    Re: Simple SQL query

    Quote Originally Posted by ganeshmoorthy
    it will not display as you expect...if you want to display like that in vb you have to code it...
    How can I display the SQL query result in form given below in Flexigrid.

    Field1----A
    Field2----B
    Field3----C


    Thanks

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Simple SQL query

    You will need to start by adding the correct number of rows to the grid (using Recordset.Fields.Count ), then add the field names if you want (using Recordset.Fields(X).Name ), and finally add the data one column at a time.

    See the "Fill a flexgrid" link in my signature for the 'normal' way to fill a flexgrid, which should give you some ideas for the code.

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Simple SQL query

    If you are using MS SQL 2005 you can return a query like that - what is your backend DB?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2003
    Posts
    253

    Re: Simple SQL query

    Quote Originally Posted by szlamany
    If you are using MS SQL 2005 you can return a query like that - what is your backend DB?
    I am using MSSQL server for my backend database.

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Simple SQL query

    2000 or 2005?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2003
    Posts
    253

    Re: Simple SQL query

    Quote Originally Posted by szlamany
    2000 or 2005?

    MSSQL 2000

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Simple SQL query

    Well - 2000 doesn't have the functionality for that.

    It is most likely easier to do as Si suggested - you know the number of columns from the returned recordset - you will need to loop through each column and add a row to the flexgrid - putting the HEADING of the column into that first flexgrid cell of each row.

    Then as you loop through the rows of data in the recordset add a new column to the flexgrid - and since you are adding them in such a strange fashion it's probably easiest to use the .TEXTMATRIX(x,y) property of the flexgrid to actually load the data.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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