Solved

Batch update, input from a form

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Out in left field or not to far off base 8 70
Access VBA Expected end of statement 5 54
SUBFORM on ACCESS 2013 8 37
VBA Ref Table, use ID#, then ref column 2 3 24
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.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

710 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