Solved

Batch update, input from a form

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
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 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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now