?
Solved

Syntax error

Posted on 2014-09-11
11
Medium Priority
?
239 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 2000 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 2000 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 2000 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
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

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 2000 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 2000 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This video teaches users how to migrate an existing Wordpress website to a new domain.
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.
Suggested Courses

801 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