Re: Parameterized Queries - Variables, and Access



Peter Nimmo wrote:
Hi,

I usually write ADO code to access SQL Server Databases, but at the
moment I am writing code interfacing with Access 2003 instead.

Normally in situations where two or more SQL statements are needed
that use the same filter in the WHERE condition I declare a variable
using:

DECLARE @VarName <variabletype> SET @VarName = ?

and then I can use @VarName in both sets of WHERE clauses. This
works fine against SQL Server but fails against Access.

I want to delete from two separate tables within the same Command
object. Is there a special syntax to declare variables in Access
specific SQL?

Jet does not support batched statements so the idea of executing two
statements with a single command has to be abandoned.


Otherwise in what way do you solve this problem.

My only other solution at the moment is to use two ? placeholders and
declare two identical Parameters in the Parameters collection.

Do you mean you have this working? Please show us an example.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Parameterized Queries - Variables, and Access
    ... I usually write ADO code to access SQL Server Databases, ... I am writing code interfacing with Access 2003 instead. ... Is there a special syntax to declare variables in Access specific SQL? ... declare two identical Parameters in the Parameters collection. ...
    (microsoft.public.data.ado)
  • [NT] Microsoft SQL Server 2000 OpenDataSource Buffer Overflow
    ... Microsoft's database server SQL Server 2000 has a remotely exploitable ... Please see the "Fix Information" section for more details. ... attacker in an exploit of the overflow will run uninhibited. ... declare @saved_return_address nvarchar ...
    (Securiteam)
  • Re: Timing out????
    ... I didn't know the column name from tbDateDiff. ... Vyas, MVP ... and means something different to SQL Server. ... > DECLARE @IPResetCount BIGINT ...
    (microsoft.public.sqlserver.programming)
  • Re: Assertion: SQL Server 2000 cant issue a SOAP call
    ... > middle tier) and not in SQL Server. ... > the SOAP endpoint. ... > sp_OA* family of system stored procedures to invoke this COM component. ... > DECLARE @object INT ...
    (microsoft.public.sqlserver.programming)
  • Re: 17805 Starting up Java App server, with SQL Server 2000 Backend
    ... network issue although you would expect a network issue to be more random. ... declare @P1 int ... On another machine running SQL Server 2000 Standard on Win2K advanced, ...
    (microsoft.public.sqlserver.clients)