Solved

Batch update, input from a form

Posted on 2004-04-07
5
418 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
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 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