Solved

Syntax error

Posted on 2014-09-11
11
235 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to count occurrences of each item in an array.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

772 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