Solved

Syntax error

Posted on 2014-09-11
11
231 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 32

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 32

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 32

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
 

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 32

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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 32

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 32

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now