"Invalid SQL statement" error when trying to execute SQL Server stored procedure from Access -
i'm operating on virtual machine sql server , ms access sit. set odbc connection access sql , linked few tables. can perform usual operations on these tables (select/update etc.).
but, i'm unable run stored procedure weird reason! procedure runs on ssms not when call access vba. following code i'm using execute proc (i need pass 3 parameters well, i've excluded code below simplicity):
with currentdb.querydefs("qpass") .sql = "exec [hs].[spgetxmlextract]" .execute end
the error returned ms access
invalid sql statement: expected 'delete', 'insert', 'procedure', 'select', or 'update'.
don't know if happening because: 1. i've got these applications on vm; and/or 2. need somehow link stored procedure ms access did tables (perhaps can't done).
i guess there convoluted methods 'might' able adopt don't want to. example:
1. create table in sql columns store parameters; write after update
trigger on table executes stored procedure; fire 'update' query ms access update parameters in table , sql trigger gets fired. or;
2. eliminate stored procedure equation , execute it's individual statements (select/update/insert etc.) through sub in ms access. don't know if cause problems creating temp tables though.
can please advise on this, real blocker!
thanks in advance!
you receive error message if querydef not have valid "odbc;..."
connection string .connect
property. how access identifies querydef pass-through query.
if have odbc linked table defined, can use .connect
property value .connect
property of querydef, so:
dim cdb dao.database set cdb = currentdb dim qdf dao.querydef set qdf = cdb.createquerydef("") qdf.connect = cdb.tabledefs("dbo_table1").connect ' grab .connect string linked table qdf.sql = "exec [hs].[spgetxmlextract]" qdf.returnsrecords = false qdf.execute
... or, if stored procedure in fact return result set:
dim cdb dao.database set cdb = currentdb dim qdf dao.querydef set qdf = cdb.createquerydef("") qdf.connect = cdb.tabledefs("dbo_table1").connect ' grab .connect string linked table qdf.sql = "exec [hs].[spgetxmlextract]" qdf.returnsrecords = true dim rst dao.recordset set rst = qdf.openrecordset(dbopensnapshot) until rst.eof ' stuff rst.movenext loop rst.close
Comments
Post a Comment