Re: Parameterized Queries - Variables, and Access
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Thu, 30 Nov 2006 08:38:58 -0500
Peter Nimmo wrote:
"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote inWhat is your objection to stored procedures?
news:ONxjNkHFHHA.3288@xxxxxxxxxxxxxxxxxxxx:
Nope, sorry Bob. That was my next plan of attack based on myOtherwise in what way do you solve this problem.Do you mean you have this working? Please show us an example.
My only other solution at the moment is to use two ? placeholders
and declare two identical Parameters in the Parameters collection.
understanding from SQL Server, but as you say Access does not support
batched queries.
I would be interested to know if there is a better way when using SQL
Server, than my method using DECLARE. I once tried to use the
variable name that I setup with the parameters collection but of
course this kind of named parameters does not work with parameterized
queries only stored procedures.
The best solution would be a stored procedure. At its simplest it would
look like:
create procedure DelRows (@id as int) as
set nocount on
delete table1 where id = @id
delete table2 where id = @id
Of course you would add error-handling and perhaps explicit transaction
rollbacks.
This could be executed via ADO as simply as:
'conn is an open connection object
conn.DelRows id
Or you could go to the trouble of creating an explicit command object
and explicitly appending a parameter object to its parameters
collection - overkill for this procedure IMO.
I would do something similar in Access, subject to the limitation
against batched queries of course. Two saved parameter queries would be
my path:
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=e6lLVvOcDHA.1204%40TK2MSFTNGP12.phx.gbl
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&selm=eHYxOyvaDHA.4020%40tk2msftngp13.phx.gbl
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
.
- References:
- Parameterized Queries - Variables, and Access
- From: Peter Nimmo
- Re: Parameterized Queries - Variables, and Access
- From: Bob Barrows [MVP]
- Re: Parameterized Queries - Variables, and Access
- From: Peter Nimmo
- Parameterized Queries - Variables, and Access
- Prev by Date: Re: Parameterized Queries - Variables, and Access
- Next by Date: Differences in SQL Dialect between Access and SQL Server (Excess Brackets)
- Previous by thread: Re: Parameterized Queries - Variables, and Access
- Next by thread: Differences in SQL Dialect between Access and SQL Server (Excess Brackets)
- Index(es):
Relevant Pages
|
|