Initialize values as "?" and the add ",?" to it for each of the count in the
array.

eg:


 String values="?";

if (stud_no==1)value="?";
else
for(int i=1;i<stud_no;i++){
values=values+",?";
}

select name, age from student where stud_no in ("+values+")";

Hope this helps,

Bye,
SJ

----- Original Message -----
From: "Chin Sung Kit" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 08, 2000 3:27 PM
Subject: Re: prepared statement problem


hi,

i have a question on preparedstatement.

i get the parameter values from the form submitted
String[] stud_no = request.getParameterValues("stud_no");

and the question is how do i set the values into the preparedstatement, for
i dont
know how many stud_no is the user going to submit.

select name, age from student where stud_no in (?, ?, ?, ?, ?)

thanks for any help and suggestions.

ced

PIYUSH NIGAM wrote:

> It is essential that your database allows nulls for values not being
> updated.Also your insert statement must include the field names in which
you
> are inserting values:
> inser into test(name,score) values(?,?)
> Piyush Nigam
>
> -----Original Message-----
> From: Synu Jacob Vengal [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 08, 2000 10:33 AM
> To: [EMAIL PROTECTED]
> Subject: prepared statement problem
>
> > > Hi,
> > > I am using a prepared statement to insert values into the database
> > fields.
> > > Is it always necessary that we should insert data in all the fields or
> > else null values??
> > > for eg. i gave the sql as
> > > sql ="INSERT INTO test VALUES(?,?)";
> > > when the actual table contained 3 fields.
> > > When i skipped one field it shows the following error
> > > java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid
argument
> > value
> > > Pls give me a solution.
> > > Thanks ,
> > > SJ
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets



"Never let yesterday's disappointments overshadow  tomorrow's dreams"

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to