Pass-through query

  • Thread starter Thread starter snaprick
  • Start date Start date
S

snaprick

Guest
Whenever I do a pass-through query with no return I get an error message on the "Execute" command "invalid sql statement"? Could anyone tell me why. It works when I do a select query but not just to execute a stored procedure. I running it on an ODBC server. Below is the function:

Function ExecuteSPT (sqltext As String, connectstring As String)

' Purpose: Run a temporary pass-through query.
' Accepts: sqltext: SQL string to run.
' connectstring: Connection string, which must be at least
' "ODBC;".
' Returns: nothing.

Dim mydb As Database, myq As QueryDef
Set mydb = DBEngine.Workspaces(0).Databases(0)

' Create a temporary QueryDef object that is not saved.
Set myq = mydb.CreateQueryDef("")

' Set the ReturnsRecords property to False in order to use the
' Execute method.
myq.returnsrecords = False

myq.connect = connectstring
myq.sql = sqltext

myq.Execute
myq.Close

End Function
 
I seem to recall this may be caused by SQL svr returning a summary even when no data is requested in return. One way is to set an option in the stored proc to inhibit a return if no data is to be sent back. My memory fails me but it may be called something like 'NoShow'??? in the Stor Proc
Sorry couldn't be more help....
 

Users who are viewing this thread

Back
Top Bottom