I'm operating on a virtual machine where my SQL server and MS Access sit. I set up an ODBC connection from Access to SQL and linked a few tables. I can perform the usual operations on these tables (select/update etc.).
BUT, I'm unable to run a stored procedure for some weird reason! The procedure runs perfectly on SSMS but not when I call it from Access VBA. Following is the code I'm using to execute the proc (I need to pass 3 parameters as well, but I've excluded that from the code below for simplicity):
With CurrentDb.QueryDefs("qPass")
.SQL = "exec [HS].[spGetXMLExtract]"
.Execute
End With
The error returned by MS Access is
Invalid SQL statement: expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
Don't know if this is happening because: 1. I've got these applications on a VM; and/or 2. I need to somehow link the stored procedure to MS Access just like I did for the tables (perhaps this can't be done).
I guess there are convoluted methods I 'might' be able to adopt but I don't want to. Example:
1. Create a table in SQL with columns that store the parameters; Write an AFTER UPDATE Trigger on that table which executes my stored procedure; Fire an 'Update' query from MS Access that would update the parameters in that table and a SQL trigger then gets fired. OR;
2. Eliminate the stored procedure from the equation completely and execute it's individual statements (select/update/insert etc.) through a Sub in MS Access. Don't know if this would cause problems with creating temp tables though.
Can someone please advise on this, this is a real blocker!
Thanks in advance!
ReturnsRecords= False ? -- What if you run that query manually?