Solved

Batch update, input from a form

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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 …

713 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