943,587 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 16378
  • JSP RSS
Mar 30th, 2006
0

inserting multiple selection from checkbox in to one column

Expand Post »
Hi,


Hoe to insert multiple selection from checkbox(from jsp) in to one column of the table(sql server database ).


Anyone can you help me?

Thanx
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
muthumari is offline Offline
20 posts
since Mar 2006
Mar 30th, 2006
0

Re: inserting multiple selection from checkbox in to one column

With a prepared statement and multiple executes.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Mar 30th, 2006
1

Re: inserting multiple selection from checkbox in to one column

Quote originally posted by masijade ...
With a prepared statement and multiple executes.



Hi,
Thanx for your reply . I know, how to retreive the checkbox value(using prepared statement with request.getParameteVales("checkboxname")).



But, It will return an array of values.
I don't know about how to insert this array of values into single column of the table(sqlserver database).
Reputation Points: 10
Solved Threads: 0
Newbie Poster
muthumari is offline Offline
20 posts
since Mar 2006
Mar 30th, 2006
0

Re: inserting multiple selection from checkbox in to one column

No What I meant was using the JDBC prepared statement. here an example:

JSP Syntax (Toggle Plain Text)
  1. String[] vals = request.getParameterValues("checkbox");
  2. try {
  3. PreparedStatement pStmt = conn.prepareStatement("Insert into table (field) values (?)");
  4. for (String val : vals) {
  5. pStmt.setString(1, val);
  6. pStmt.execute();
  7. }
  8. } catch .....

of course replacing checkbox, table, and field with the real things.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Mar 30th, 2006
0

Re: inserting multiple selection from checkbox in to one column

Quote originally posted by masijade ...
No What I meant was using the JDBC prepared statement. here an example:

JSP Syntax (Toggle Plain Text)
  1. String[] vals = request.getParameterValues("checkbox");
  2. try {
  3. PreparedStatement pStmt = conn.prepareStatement("Insert into table (field) values (?)");
  4. for (String val : vals) {
  5. pStmt.setString(1, val);
  6. pStmt.execute();
  7. }
  8. } catch .....

of course replacing checkbox, table, and field with the real things.


Hi i have one error in this line:

pStmt.setString(1, val);


The error is ; expected.
I haven't any idea about this

Can you help me
Reputation Points: 10
Solved Threads: 0
Newbie Poster
muthumari is offline Offline
20 posts
since Mar 2006
Mar 30th, 2006
0

Re: inserting multiple selection from checkbox in to one column

Are you using jdk 1.5 or an earlier version. If you are not using 1.5 then the following lines
must be changed:

JSP Syntax (Toggle Plain Text)
  1. for (String val : vals) {
  2. pStmt.setString(1, val);
  3. pStmt.execute();

to:

JSP Syntax (Toggle Plain Text)
  1. for (int i = 0; i < vals.length; i++) {
  2. pStmt.setString(1, vals[i]);
  3. pStmt.execute();
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Oct 15th, 2009
-1
Re: inserting multiple selection from checkbox in to one column
multiple checkbox & textfield insert in Oracle9i using Jsp
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alokranjan.java is offline Offline
1 posts
since Oct 2009
Oct 15th, 2009
-1
Re: inserting multiple selection from checkbox in to one column
multiple checkbox & textfield insert in Oracle9i using Jsp
It is bad enough that you reopened old thread you did not even provided proper description of whatever you up to. Do you mind to correct your mistake?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,653 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: can some one help me
Next Thread in JSP Forum Timeline: problem in importing package





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC