This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing parameters using Prepared Statement

 
C Vivek
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above code does not return anything in the ResultSet whereas if I hardcode value instead of the "?" in the query string, it executes properly.

 
Campbell Ritchie
Sheriff
Posts: 48642
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That "like" would return an item name with a ? in. Is that what you really want?
 
Janardan Kelkar
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should'nt the code be something like this? :
 
C Vivek
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Janardhan,
That worked, however is there something in the code that makes it retrieve only a single record?

When I run the query in the Backend it does return the exact no of records (which can be more than 1) however in the prepared statement in the code above it is retrieving only one.

Would be glad if you can help me here.


Regards,
Vivek

 
Paul Yule
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so. How are you iterating the results?
 
Janardan Kelkar
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace the 'if' on line 14 in your code with a 'while'. that should do it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic