Solved

Syntax error

Posted on 2014-09-11
11
236 Views
Last Modified: 2014-09-11
I have a script that updates a table in the database when payments are made but I am getting a syntax error:

-- code --

<%
Response.Buffer = True

       'First, we need to get the total number of items that could be updated
       Dim iCount3
       iCount3 = Request.Form("Count")

       'We need to obtain each Link and ID
       Dim strLink3, strID3, strBalance3

Dim strSQL3
Dim Command13
set Command13 = Server.CreateObject("ADODB.Connection")
Command13.ConnectionString = MM_eimmigration_STRING
Command13.Open

Dim iLoop3
     
For iLoop3 = 0 to iCount3
    strLink3 = Request(iLoop & ".Link")
 strBalance3 = Request(iLoop & ".Balance")
    strID3 = Request(iLoop & ".ID2")
      strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance) + ccur(strLink) & "  " &_
      " WHERE Id = " & strID


Command13.Execute strSQL3



Next
Command13.Close
       Set Command13 = Nothing

     
%>

--   error --

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.

/bluedot/Intranet/Billing/Payments/PaymentSavedUpdatepaymnt.asp, line 34
0
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 40317073
you don't have a strID variable, I think it should be strID3:

 strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance) + ccur(strLink) & "  " &_
      " WHERE Id = " & strID3
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 40317080
in fact, you need to add a "3" to all of your variable names:

 strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance3) + ccur(strLink3) & "  " &_
      " WHERE Id = " & strID3
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 40317089
you're also setting yourself up to be targeted by sql injection attacks, you may want to use parameterized queries instead
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:amucinobluedot
ID: 40317092
I did notice that typo, I added it but still get the same error:

-- code

<%
Response.Buffer = True

       'First, we need to get the total number of items that could be updated
       Dim iCount3
       iCount3 = Request.Form("Count")

       'We need to obtain each Link and ID
       Dim strLink3, strID3, strBalance3

Dim strSQL3
Dim Command3
set Command3 = Server.CreateObject("ADODB.Connection")
Command3.ConnectionString = MM_eimmigration_STRING
Command3.Open

Dim iLoop3
     
For iLoop3 = 0 to iCount3
    strLink3 = Request(iLoop & ".Link")
 strBalance3 = Request(iLoop & ".Balance")
    strID3 = Request(iLoop & ".ID2")
      strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance) + ccur(strLink) & "  " &_
      " WHERE Id = " & strID3


Command3.Execute strSQL3



Next
Command3.Close
       Set Command3 = Nothing

     
%>

-- error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.

/bluedot/Intranet/Billing/Payments/PaymentSavedUpdatepaymnt.asp, line 34


--

Line 34 is: Command3.Execute strSQL3
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 40317105
you need to fix the other variables as well:

strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance) + ccur(strLink) & "  " &_
      " WHERE Id = " & strID3
0
 

Author Comment

by:amucinobluedot
ID: 40317114
I did, same error

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.

/bluedot/Intranet/Billing/Payments/PaymentSavedUpdatepaymnt.asp, line 34
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 500 total points
ID: 40317119
did you add a 3 to the variable names i highlighted above?
0
 

Author Comment

by:amucinobluedot
ID: 40317136
This is the code for the whole page. Only the top part is giving issues:

----

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

-- THIS IS THE PART OF THE CODE THAT GIVES THE ERROR --

<%
Response.Buffer = True

       'First, we need to get the total number of items that could be updated
       Dim iCount3
       iCount3 = Request.Form("Count")

       'We need to obtain each Link and ID
       Dim strLink3, strID3, strBalance3

Dim strSQL3
Dim Command3
set Command3 = Server.CreateObject("ADODB.Connection")
Command3.ConnectionString = MM_eimmigration_STRING
Command3.Open

Dim iLoop3
     
For iLoop3 = 0 to iCount3
    strLink3 = Request(iLoop & ".Link")
 strBalance3 = Request(iLoop & ".Balance")
    strID3 = Request(iLoop & ".ID2")
    strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance) + ccur(strLink) & "  " &_
       " WHERE Id = " & strID3


Command3.Execute strSQL3



Next
Command3.Close
       Set Command3 = Nothing

     
%>


<!--#THE REST OF THE CODE WORKS FINE-->

<%
Response.Buffer = True

       'First, we need to get the total number of items that could be updated
       Dim iCount
       iCount = Request.Form("Count")

       'We need to obtain each Link and ID
       Dim strLink, strID

Dim strSQL
Dim Command1
set Command1 = Server.CreateObject("ADODB.Connection")
Command1.ConnectionString = MM_eimmigration_STRING
Command1.Open

Dim iLoop
     
For iLoop = 0 to iCount
    strLink = Request(iLoop & ".Link")
    strID = Request(iLoop & ".ID")
      strSQL = "UPDATE BillPaymntsRecvd SET PmtRecd = " & strLink & "  " &_
      " WHERE PaymntId = " & strID
 

Command1.Execute strSQL
Next

Command1.Close
       Set Command1 = Nothing

       
%>



<html>
<head>
<title>Registering Payment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<link href="../../../css/home.css" rel="stylesheet" type="text/css">
</head>


<body>
<div align="center">
  <p class="bodytext">&nbsp;</p>
  <p class="bodytext">&nbsp;</p>
  <p class="bodytext">Please wait ... registering payment </p>

</div>
</body>
</html>

<!--#BeginBlock-->

<script language="javascript">
window.location.href="../UpdatePayments.asp";
</script>
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 40317144
for the third time then, change

strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance) + ccur(strLink) & "  " &_
       " WHERE Id = " & strID3

to

strSQL3 = "UPDATE BillingLines SET PmtRecd = " & ccur(strBalance3) + ccur(strLink3) & "  " &_
       " WHERE Id = " & strID3
0
 

Author Comment

by:amucinobluedot
ID: 40317147
In fact it was the iloop that needed the 3 added. No errors now but it is not updating the table values  :#
0
 

Author Closing Comment

by:amucinobluedot
ID: 40317154
Thanks for the patience !
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question