Solved

Batch update, input from a form

Posted on 2004-04-07
5
423 Views
Last Modified: 2012-08-13
Having this piece of code:

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="prov/adovbs.inc"-->
<%
       Response.Buffer = True

      Dim objConn         ' Connection Name
      Dim strConnString   ' Connection String
      Dim objRS           ' Recordset Variable
      Dim strSQL          ' variable for SQL statement
      Set objConn = Server.CreateObject("ADODB.Connection")
      Set objRS   = Server.CreateObject("ADODB.Recordset")
      strConnString = "DBQ=" & Server.MapPath("prov/databas/Medlem.mdb")
      objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & strConnString
      Dim var
      'var = request("var")
      response.write var
       strSQL = "UPDATE ÖSFK SET Betalt = date() WHERE ID IN ( & var)"

           objConn.Execute strSQL

       objConn.Close
       Set objConn = Nothing


       Response.Redirect "updatesql.asp"
%>

From a form I give the input, var, (uncommenting the 'response.write var' verifies the input is correct). Also, if I manually enter integers (such as 5, 6, 7) instead of '& var' in the code, the code works OK.

When running the above code I get this response:

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

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Id IN ( & var)'.

/osfk.org/updatesql2.asp, line 20.

Please help me out, what is wrong and why doesn't it work?
0
Comment
Question by:lericson
[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
  • 3
  • 2
5 Comments
 
LVL 34

Accepted Solution

by:
flavo earned 500 total points
ID: 10778444
try changing strSQL = "UPDATE ÖSFK SET Betalt = date() WHERE ID IN ( & var)"

to

strSQL = "UPDATE ÖSFK SET Betalt = date() WHERE ID IN ( " & var & " )"

Dont know much bout asp, but that would work in VBA (if ID is a numeric value)
0
 

Author Comment

by:lericson
ID: 10778639
flavo,

you are correct in assuming ID is a numeric value. Tried your suggestion, got this reply:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Id IN ( & var &)'.
/osfk.org/updatesql2.asp, line 20.
0
 

Author Comment

by:lericson
ID: 10778704
Also tried ( " & var &" ) as you suggested (oversaw it at first, was too eager to try...). Got this reply:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Id IN ( )'.
/osfk.org/updatesql2.asp, line 20
0
 

Author Comment

by:lericson
ID: 10778968
flavo,

Your suggestion is correct. Unfortunately, I had a typo in another place (embarrasingly enogh).

Thanks for your very speedy response.
0
 
LVL 34

Expert Comment

by:flavo
ID: 10779167
To easy, i hate that!

Dave
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

636 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