Results 1 to 3 of 3

Thread: SQL and VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    4

    Question

    I am wanting to allow the user to click Sort Ascending or Sort Descending and have a datagrid sort by name accordingly. How can this be done w/ SQL or is there an easier way to do this?

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Feb 2000
    Posts
    284
    At the end of your SQL statement use the ORDER BY clause and select the field you wish to order by eg.

    Select * from Customers
    Order By LastName

    You can also specify Asc/Desc dependiong on which you want, default is Asc.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    4

    Question VB and SQL

    Here is a sample of the code I am using.....Right now I have menu as follows....

    Sort
    Sort Asc
    Sort Desc

    But when I click these nothing happens

    Here is the code in the Sort Desc routine

    cDbase = "C:\PhoneDirectory.mdb"
    cTable = "Directory"
    cSort = " ORDER BY "
    cField = ""
    cSelect = "SELECT * FROM "
    cTry = "SORT DESC"

    Adodc1.RecordSource = cSelect + cTable + cSort + "Name"

    DataGrid1.Refresh

    Any suggestions?

    Thanks

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