hi,
 You are getting syntax error since your SQL syntax in incorrect.
One method you can adopt is first select all records to be inserted into a
recordset.
Then write your prepare statement i.e.
"insert into TableName (Name, Age, ?,?, Sponser_Name,  Sponser_country) "
Then use prepare statement setString() to insert into the table (get value
from the record set)

Hope this will help you
Cheers,
Sanjay

-----------------------------------------------------------------
Sanjay Kumar,
Software Consultant,
Addcon India Pvt Ltd.
New Delhi.

Emails : [EMAIL PROTECTED]
             [EMAIL PROTECTED]

Phones : 6423907,6201330 (Office)
    "Keep Smilling. It does increase your face value"

-----------------------------------------------------------------






----- Original Message -----
From: Rathinavel Palaniappan <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 12, 2000 9:46 AM
Subject: How to set String values in PreparedStatement?


> hi folks,
>
>      Sorry for bit off topic question, but i hope somebody
>      can thru light on it!.
>
>      I have problem on setting String values in the
>      prepared statement.I have a sql statement
>      somthing like,
>
>       "insert into TableName (Name, Age, ?,?, Sponser_Name,
>        Sponser_country)  select tbl.Name,tbl.Age,tbl.Address1,
>       tbl.Address2, tbl.Sponser_Name,tbl.Sponser_country from
>       tbl";
>
>        (This is to copy data form one table to another table)
>
>       here i want to set the coloumn name at run time by using
>       prepareStatement setString. but i am getting exception
>      "syntax error in INSERT INTO statement" when execute
>      the query.
>
>     so how could i set the values using setString? FYI, setString
>     of prepareStatement works when the '?' appears in the
>     'where' clause.
>
> thanks for your time,
>
> with regards,
>            rathna.
>
>
===========================================================================
> 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