PC Review


Reply
Thread Tools Rate Thread

Calling Parameterized Query Using SQL Syntax

 
 
Vern DeHaven
Guest
Posts: n/a
 
      17th Nov 2010

I've got the following parameterized query (ParamQuery) in Access 2000
(compatibility mode):

PARAMETERS [myInteger] INTEGER;
SELECT *
FROM SourceTable
WHERE Value = [myInteger];

The software I'm using forces me to fire a SQL query through the
Connection object. I unfortunately do not have access to the
QueryDefs object to set parameters. I'd like to call this query from
an SQL statement as I am able to do against an SQL Server database and
function:

oConn.Execute("SELECT * FROM ParamQuery(3)")

However, this syntax is not supported in Access; I receive a "Syntax
error in FROM clause" error. I have also tried to use "EXEC
ParamQuery 3" to no avail; I receive an "Invalid SQL statement:
Expected 'DELETE', 'INSERT", 'PROCEDURE', 'SELECT', or 'UPDATE'"
error.

Any help is appreciated,
Vern
 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      18th Nov 2010
Vern DeHaven wrote:
> I've got the following parameterized query (ParamQuery) in Access 2000
> (compatibility mode):
>
> PARAMETERS [myInteger] INTEGER;
> SELECT *
> FROM SourceTable
> WHERE Value = [myInteger];
>
> The software I'm using forces me to fire a SQL query through the
> Connection object.


ADO connection?

> I unfortunately do not have access to the
> QueryDefs object to set parameters. I'd like to call this query from
> an SQL statement as I am able to do against an SQL Server database and
> function:
>
> oConn.Execute("SELECT * FROM ParamQuery(3)")


If this is an ADO Connection, then stored procedures (which is what your
saved query is considered) are exposed as connection methods to whch you can
pass arguments to parameters much the same as you can to native connection
methods. In your case, it would look like this:

set rs = oConn.ParamQuery(3)

If the saved query was an action query (INSERT, UPDATE, DELETE, etc.) that
returns no records, then you would do this:

oConn.ParamQuery 3

>
> However, this syntax is not supported in Access; I receive a "Syntax
> error in FROM clause" error. I have also tried to use "EXEC
> ParamQuery 3" to no avail; I receive an "Invalid SQL statement:
> Expected 'DELETE', 'INSERT", 'PROCEDURE', 'SELECT', or 'UPDATE'"
> error.
>

If you can't use a DAO querydef, or an ADO Connection, then you're out of
luck.


 
Reply With Quote
 
Vern DeHaven
Guest
Posts: n/a
 
      18th Nov 2010
> ADO connection?

My apologies, it's a DAO Connection object.

> If you can't use a DAO querydef, or an ADO Connection, then you're out of
> luck.


I'm dealing with a software package I can't modify. I am merely able
to throw SQL statements at the DAO Connection object. Thanks for the
info Bob.
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      18th Nov 2010
Vern DeHaven wrote:
>> ADO connection?

>
> My apologies, it's a DAO Connection object.
>
>> If you can't use a DAO querydef, or an ADO Connection, then you're
>> out of luck.

>
> I'm dealing with a software package I can't modify. I am merely able
> to throw SQL statements at the DAO Connection object. Thanks for the
> info Bob.


Time to dash off an email to the software vendor requesting support for
querydefs ...


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forgot Syntax: calling a parameterized constructor of the same class from a non-parameterized one Sathyaish Microsoft C# .NET 5 5th Apr 2007 02:25 PM
Parameterized query syntax RipperT Microsoft Access Queries 2 2nd Feb 2006 12:07 AM
Calling parameterized query from ASP - which datatype constant to use? Terry Microsoft Access Queries 2 10th Jan 2006 11:45 PM
syntax for calling Query with parameter from VB =?Utf-8?B?Y29uZnVzZWQ=?= Microsoft Access VBA Modules 9 16th Sep 2004 12:55 PM
Calling Jet 4.0 Parameterized Queries from ADO.NET Otis Mukinfus Microsoft ADO .NET 8 27th Dec 2003 01:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:22 PM.