
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 ?