Parameters in INSERT query problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: MJS (a_at_b.com)
Date: 03/21/05


Date: Mon, 21 Mar 2005 15:27:22 -0600

I have a query that works.... but I want to clean it up, using ?'s for the
parameters in the query... but I am having a problem, I keep getting an
error: "Run-time error '3001': Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another.".

Like I stated... the query in this format works:

                cmd.CommandText = "INSERT INTO MyTable(SomeString1, SomeInt,
SomeString2) VALUES('" & _
                                    str1 & "'," & _
                                    int1 & ",'" & _
                                    str2 & "')"

But I want to simplify the CommandText string... and use queries like the
following... some of my queries will have many params.
    cmd.CommandText = "INSERT INTO MyTable(SomeString1, SomeInt,
SomeString2) VALUES(?,?,?)"
Set rst = cmd.Execute(Parameters:=Array(str1, int1, str2))

I am able to do this successfully if I have only one ?, but when I have
multiple, it doesn't want to work.

Any Ideas?



Relevant Pages

  • RE: Dynamically referencing a recordset?
    ... through that recordset to set the query parameters in VBA. ... to be the one who had to modify 1440 queries if there is a change in the ... different table schema, then you need 3, one for each record type. ... This is a database that tracks the production on records in another ...
    (microsoft.public.access.modulesdaovba)
  • Re: Was: what does "serialization" mean?
    ... > the specific queries up front. ... that the NEXT time the query is run the query is fast, ... data base, don't know squat" when in fact the Donald clone doesn't ... >> WHATEVER would probably be a separate query to summarize total sales. ...
    (comp.programming)
  • Re: Official Status of SQLServer 2005 ADP
    ... I have said that the support for SQL passthrough ... queries under MDB was bad and worst than the one offered by ADP while you ... > attempt to "pass through" every Access query against a linked ODBC ...
    (microsoft.public.access.adp.sqlserver)
  • Re: "Query Too Complex" Errors
    ... few dozens of queries, in the middle of which there's a long chain of ... we've been having a lot of those "Query Too ... some of the complexity in the SQL ... SQL statement you are working on. ...
    (microsoft.public.access.forms)
  • Re: Cluster synchronize
    ... queries per unit time. ... CPU is the ONLY bottleneck. ... increase in query capacity. ... queries that perform sequential I/O or queries performing random I/O. ...
    (microsoft.public.sqlserver.clustering)