Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameter to sql query 1

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
GB
hello,
how do I pass a parameter to an sql query ?
I can type into a text box then submit it to a servlet, then open another jsp showing the typed parameter, but if I try to add the parameter like below no data is displayed :

String queryString = "SELECT name, Postcode, County FROM Establishments WHERE Postcode = "+Est_Postcode+" ORDER BY name ";


any ideas ?
 
if Est_Postcode is a string, there should be single quotes around it as such:

String queryString = "SELECT name, Postcode, County FROM Establishments WHERE Postcode = '" + Est_Postcode + "' ORDER BY name ";
 
damn, I shoulod have known that. (same as ASP)

cheers mmaz !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top