CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2007
    Location
    Everything, in its right place.
    Posts
    50

    ORDER BY in Netbeans...

    Hey all, I've got a question. How would one ORDER BY *insert column name* in Netbeans? I know how to use it in the "execute command" part for the database itself...

    SELECT HOLIDAY, CUSTOMER, DATE FROM WAITLIST ORDER BY DATE

    Which then orders it by date, but I want to have a function (in one of my classes) execute that command so it reorganizes the database table from that class, but I'm not sure how to set up the function... I thought something like a simple void function and:

    orderWait.executeQuery();

    would work, but obviously not. Any help would be appreciated.


    Also, I am using prepared statements to access the database, so that's not the problem either.
    Last edited by Blind Melon; April 27th, 2008 at 08:00 PM.
    I need a map of your head,
    Trans-lated into English,
    So I can learn to not make you frown.

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: ORDER BY in Netbeans...

    Quote Originally Posted by Blind Melon
    ... I want to have a function (in one of my classes) execute that command so it reorganizes the database table from that class
    Can you explain what you mean a little more clearly - perhaps a couple of examples might help...

    If you want to make the column name in the 'ORDER BY' clause a variable, you just tack a String variable into your SQL expression:
    Code:
    String sqlExpression =  "... ORDER BY " + columnName;
    A prudent question is one-half of wisdom...
    F. Bacon
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

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

Featured