04-12-13, 16:26 #1Registered User
- Join Date
- Apr 2013
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.
04-21-13, 18:37 #2(Making Your Life Easy)
Provided Answers: 10
- Join Date
- Feb 2004
- New Zealand
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
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
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