#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2016
    Posts
    16
    Rep Power
    0

    Angry ASP Error can't identify the fault


    Hi,

    I am trying to create a page that allows the user to delete multiple rows from a datasource.

    When I press the 'Submit' button I get the following error;

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

    [Sybase][ODBC Driver][Adaptive Server Anywhere]Syntax error near ')' on line 1

    /DML/index.asp, line 44"

    I can't seem to see where the error is ! My code so far is below, any help would be great!

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include file="Connections/PSCRM.asp" -->
    <%
    ' IIf implementation
    Function MM_IIf(condition, ifTrue, ifFalse)
      If condition = "" Then
        MM_IIf = ifFalse
      Else
        MM_IIf = ifTrue
      End If
    End Function
    %>
    <%
    Dim rs_QuoteLines__MMColParam
    rs_QuoteLines__MMColParam = "1"
    If (Request.QueryString("quoteno") <> "") Then 
      rs_QuoteLines__MMColParam = Request.QueryString("quoteno")
    End If
    %>
    <%
    Dim rs_QuoteLines
    Dim rs_QuoteLines_cmd
    Dim rs_QuoteLines_numRows
    
    Set rs_QuoteLines_cmd = Server.CreateObject ("ADODB.Command")
    rs_QuoteLines_cmd.ActiveConnection = MM_PSCRM_STRING
    rs_QuoteLines_cmd.CommandText = "SELECT cn_ref, [desc], statusflag, lineid, lineno, string(lineid,cn_ref) as cb FROM dba.quotelne WHERE quoteno = ? AND statusflag = 'A' ORDER BY lineno asc" 
    rs_QuoteLines_cmd.Prepared = true
    rs_QuoteLines_cmd.Parameters.Append rs_QuoteLines_cmd.CreateParameter("param1", 200, 1, 255, rs_QuoteLines__MMColParam) ' adVarChar
    
    Set rs_QuoteLines = rs_QuoteLines_cmd.Execute
    rs_QuoteLines_numRows = 0
    %>
    <%
    If Request("Delete_Submit") <> "" Then
    Set CommUpdateSF = Server.CreateObject ("ADODB.Command")
    CommUpdateSF.ActiveConnection = MM_PSCRM_STRING
    CommUpdateSF.CommandText = "UPDATE dba.quotelne SET statusflag = 'D' WHERE quoteno = ? and string(lineid,cn_ref) IN (" + Replace(commUpdateSF__vCnref, "'", "''") + ")"
    CommUpdateSF.Parameters.Append CommUpdateSF.CreateParameter("vQuoteno", 201, 1, 10, MM_IIF(Request.QueryString("quoteno"), Request.QueryString("quoteno"), CommUpdateSF__vQuoteno & ""))
    CommUpdateSF.Parameters.Append CommUpdateSF.CreateParameter("vCnref", 200, 1, 100, MM_IIF(Request.Form("statusflag"), Request.Form("statusflag"), CommUpdateSF__vCnref & ""))
    CommUpdateSF.CommandType = 1
    CommUpdateSF.CommandTimeout = 0
    CommUpdateSF.Prepared = true
    CommUpdateSF.Execute()
    End If
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = -1
    Repeat1__index = 0
    rs_QuoteLines_numRows = rs_QuoteLines_numRows + Repeat1__numRows
    %>
    <!doctype html>
    <html>
    <head>
      <meta charset="utf-8">
    <title>Quotes - Sales Dashboard</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
      <link href="css/cmd.css" rel="stylesheet" type="text/css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/sortable.js"></script>
    </head>
    
    <body>
    	<div class="jumbotron">
        	<div class="container">
           	  <h1 font style="color:White;">Quote Tool</font></h1>
                    	<form class="form-inline" role="form">
            	<div class="form-group">
                	<label for="quoteno"><font style="color:White;">Quote No.</font> </label>
                    <input type="number" class="form-control" id="quoteno" name="quoteno">
                </div>
                <button type="submit" class="btn btn-default">Search</button>
            </form>
            </div>
        </div>
    	<div class="container">
       	  <h2>Quote Lines</h2>
          <form method="post" role="form form-group checkbox">
          <table class="table table-striped table-condensed">
          	<thead>
            	<tr>
            	  <th>&nbsp;</th>
                	<th>Part Number</th>
                    <th>Description</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
              <% 
    While ((Repeat1__numRows <> 0) AND (NOT rs_QuoteLines.EOF)) 
    %>
      <tr>
        <td><%=(rs_QuoteLines.Fields.Item("lineno").Value)%></td>
        <td><%=(rs_QuoteLines.Fields.Item("cn_ref").Value)%></td>
        <td><%=(rs_QuoteLines.Fields.Item("desc").Value)%></td>
        <td><input name="statusflag" type="checkbox" value="<%=(rs_QuoteLines.Fields.Item("cb").Value)%>">
        </td>
      </tr>
      <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      rs_QuoteLines.MoveNext()
    Wend
    %>
            </tbody>
          </table>
          <input type="submit" id="Delete_Submit" name="Delete_Submit">
          </form>
        </div>
    </body>
    </html>
    <%
    rs_QuoteLines.Close()
    Set rs_QuoteLines = Nothing
    %>
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,021
    Rep Power
    9616
    Line 44 is where you execute the query, and the query is
    asp Code:
    CommUpdateSF.CommandText = "UPDATE dba.quotelne SET statusflag = 'D' WHERE quoteno = ? and string(lineid,cn_ref) IN (" + Replace(commUpdateSF__vCnref, "'", "''") + ")"

    The error says there was a ) where one was not expected so it's surely talking about the
    asp Code:
    "IN (" + Replace(commUpdateSF__vCnref, "'", "''") + ")"

    at the end. It could mean that commUpdateSF__vCnref was empty and the query says "IN ()" or there could be some other problem with the value. Probably empty.

    Make sure the value is being set properly; if it's supposed to be empty then you need to modify your query to not use it in that case.

IMN logo majestic logo threadwatch logo seochat tools logo