Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO Syntax Error

Status
Not open for further replies.

pwinters

Programmer
Sep 12, 2002
34
PLEASE HELP....Here is my code:

<%


String initnum = request.getParameter(&quot;initnum&quot;);
String pname = request.getParameter(&quot;projname&quot;);
String status = request.getParameter(&quot;primstatus&quot;);
String stage = request.getParameter(&quot;projstage&quot;);
String month = request.getParameter(&quot;relmonth&quot;);
String spm = request.getParameter(&quot;spmid&quot;);
String pdesc = request.getParameter(&quot;desc&quot;);
if ((pdesc == null) || (pdesc.equalsIgnoreCase(&quot;null&quot;)))
pdesc = &quot;&quot;;
String adjtnum = request.getParameter(&quot;adjnum&quot;);
if ((adjtnum == null) || (adjtnum.equalsIgnoreCase(&quot;null&quot;)))
adjtnum = &quot;&quot;;
String adjtstat = request.getParameter(&quot;adjstatus&quot;);
if ((adjtstat == null) || (adjtstat.equalsIgnoreCase(&quot;null&quot;)))
adjtstat = &quot;&quot;;
String adjtdesc = request.getParameter(&quot;adjdesc&quot;);
if ((adjtdesc == null) || (adjtdesc.equalsIgnoreCase(&quot;null&quot;)))
adjtdesc = &quot;&quot;;
String lloe = request.getParameter(&quot;loadloe&quot;);
if ((lloe == null) || (lloe.equalsIgnoreCase(&quot;null&quot;)))
lloe = &quot;&quot;;





String sql =
&quot;INSERT INTO Projects &quot; +
&quot;( &quot; +
&quot;Initiative_Num, &quot; +
&quot;Project, &quot; +
&quot;Release, &quot; +
&quot;SPM_ID, &quot; +
&quot;Project_Stage, &quot; +
&quot;Primary_Status, &quot; +
&quot;Description, &quot; +
&quot;Adj_Num, &quot; +
&quot;Adj_Status, &quot; +
&quot;Adj_Description, &quot; +
&quot;Loaded_LOE &quot; +
&quot;) &quot; +
&quot;VALUES &quot; +
&quot;( &quot; +
db.formatInsertStringValue(initnum, true) + &quot;,&quot; +
db.formatInsertStringValue(pname, true) + &quot;,&quot; +
db.formatInsertStringValue(month, true) + &quot;,&quot; +
db.formatInsertStringValue(spm, true) + &quot;,&quot; +
db.formatInsertStringValue(stage, true) + &quot;,&quot; +
db.formatInsertStringValue(status, true) + &quot;,&quot; +
db.formatInsertStringValue(pdesc, true) + &quot;,&quot; +
db.formatInsertStringValue(adjtnum, true) + &quot;,&quot; +
db.formatInsertStringValue(adjtstat, true) + &quot;,&quot; +
db.formatInsertStringValue(adjtdesc, true) + &quot;,&quot; +
db.formatInsertStringValue(lloe, true) + &quot;,&quot; +
&quot;)&quot;;

int rowsAffected = db.execUpdate(sql);

//int rowsAffected = 2;
if (rowsAffected == 1)
{

response.sendRedirect(&quot;../site/epsmain_form.jsp&quot;);


}
else
{
%>
<h2>Sorry, modification has failed.</h2>
<%= sql %>
<p><a href=&quot;../site/epsmain_form.jsp&quot;>Back to Main</a>

<%
}

%>


I can't figure out what the problem is. When I enter the information on the form (in webpage), I get an error:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access 97 Driver] Syntax error in INSERT INTO statement.

Can anyone PLEASE help me figure out what is wrong. I've been looking at this and trying things for 5 days now, and nothing seems to be working.

Thanks so much.

p.s. using MSAccess 97 db with web front end.

 
The error is in the next to last line. It contains an extra comma.

db.formatInsertStringValue(lloe, true) + &quot;,&quot; +
&quot;)&quot;;

In the future, you should post Access SQL questions in forum701, the Access JET SQL forum. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Tlbroadbent,

Figures it was something so simple....Thanks so much!

I'll post these kind of questions to the other forum from now on.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top