File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string variables

 
zack chancery
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
imagine i have a string variable called myString.
i want to insert the string's value into a table of my database.
i can insert fine when the string is explicit but when it is referenced there is a problem.
e.g
s.execute("INSERT INTO Table (name) VALUES ('zack')); is fine

but

s.execute("INSERT INTO Tracker (name) VALUES (myString)); is NOT fine


***ERROR***
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
***********


BEST REGARDS,
Z
 
David Ulicny
Ranch Hand
Posts: 724
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s.execute("INSERT INTO Tracker (name) VALUES ('"+myString+"')");
[ October 04, 2004: Message edited by: David Ulicny ]
 
zack chancery
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Outstanding!!!
Thanks David,
Z
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic