Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013
    Posts
    1

    Unanswered: Using Text Box Value as the 'Where' clause in SQL query

    i'm using javadb(netbeans) for a project and I am a total beginner.

    I have a small app which searches an address database and brings back a data grid of results.

    The users tpyes in all, or part of a street name into a jtextfield, hits a search button and the records are then filtered in a data grid.

    I am writing simple sql queries which are working fine but I am struggling to indicate the where clause must be the jtextfield text. For example, what I need to do is the following:

    SELECT * FROM tbl_addresses WHERE Street_Name = jTextfield.getstring()
    but obviously that doesn't work.

    Can anybody help?? Please??
    Last edited by pank; 04-12-13 at 16:45.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,469
    Provided Answers: 10
    dont know anything about netbeans

    "SELECT * FROM tbl_addresses WHERE Street_Name = '" + jTextfield.getstring() +"'"

    note the ' you mite have to use the "
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •