Problem in querydef object 
Author Message
 Problem in querydef object

I have using the following code to send a store procedure to SQL server via
the access 2.0 database

Dim qryTemp As QueryDef

Set qryTemp = MyDatabase.CreateQueryDef("")

With qryTemp        
        .Connect = "Conection string to SQL Server"
        .sql = "store procedure name"
        .ODBCTimeout = 200
        .ReturnsRecords = True
End With

Set MyRecords = qryTemp.OpenRecordset()

When I open the recordset, I got the error : 3129 - Invalid SQL statement;
expected 'DELETE','INSERT','PROCEDURE','SELECT', or 'UPDATE'.
I am sure the connection string & store procedure is correct. Can anyone
help me to solve this problem ?



Thu, 09 Mar 2000 03:00:00 GMT  
 Problem in querydef object

Yeah, your .sql property should be some kind of SQL statement such as
"SELECT * FROM TestDB". "store procedure name" has no meaning as an SQL
statement. If you are trying to set a QueryDef equal to a previously stored
query (resident on the database), you code should be something like

Set qryTemp = MyDatabase.QueryDefs("QueryName")

 With qryTemp        
         .Connect = "Conection string to SQL Server"
         .ODBCTimeout = 200
         .ReturnsRecords = True
 End With

 Set MyRecords = qryTemp.OpenRecordset()

--
Larry Stall
Senior Engineer, Controls
Giddings & Lewis, Inc.
MS Site Builder Level II
http://www.ticon.net/~lstall/



Quote:
> I have using the following code to send a store procedure to SQL server
via
> the access 2.0 database

> Dim qryTemp As QueryDef

> Set qryTemp = MyDatabase.CreateQueryDef("")

> With qryTemp        
>         .Connect = "Conection string to SQL Server"
>         .sql = "store procedure name"
>         .ODBCTimeout = 200
>         .ReturnsRecords = True
> End With

> Set MyRecords = qryTemp.OpenRecordset()

> When I open the recordset, I got the error : 3129 - Invalid SQL
statement;
> expected 'DELETE','INSERT','PROCEDURE','SELECT', or 'UPDATE'.
> I am sure the connection string & store procedure is correct. Can anyone
> help me to solve this problem ?



Fri, 10 Mar 2000 03:00:00 GMT  
 Problem in querydef object

If you want to execute a Stored Procedure, you need to include the
'Execute' verb.  For instance:

        .sql = "EXECUTE sp_StoredProcedureName"

Cheers,
Tim.



Quote:
>With qryTemp        
>        .Connect = "Conection string to SQL Server"
>        .sql = "store procedure name"
>        .ODBCTimeout = 200
>        .ReturnsRecords = True
>End With

Tim Elley
Advance Tech Computer Solutions Ltd
Christchurch, New Zealand

A Microsoft Solution Provider



Sat, 11 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem with QueryDef objects and/or SQL

2. Delete existing QueryDef object

3. QueryDef Object doesn't fail

4. Enumerating QueryDef Objects

5. Update query with querydef object

6. The Emptiness of the ValidationRule Property on QueryDef Objects

7. Question for anyone who has used parameter queries with querydef objects in VB

8. DAO Querydef Object in ADO?

9. Can I use queryDef objects as stored procedures?

10. To Few Parameter, Expecting XX in Querydef object

11. Question for anyone who has used parameter queries in querydef objects under VB

12. QueryDef Object HELP!

 

 
Powered by phpBB® Forum Software