programmher
asked on
Error when executing a job from MSAccess
Hello.
I have a customer who has an Access application.
The last step of the Access application needs to start a job in SQL server.
This is what I have in my pass-through query:
SET NoCount ON ;
EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';
I get this error:
Pass-through query with ReturnsRecords property set to True did not return any records.
I have tried including a DoCmd.SetWarnings =False;- this does not work.
I do not see any default setting within my ODBC connection that I can update to resolve this error.
What command can I include in my pass-through query to resolve this error, execute this job, and complete my task?
I have a customer who has an Access application.
The last step of the Access application needs to start a job in SQL server.
This is what I have in my pass-through query:
SET NoCount ON ;
EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';
I get this error:
Pass-through query with ReturnsRecords property set to True did not return any records.
I have tried including a DoCmd.SetWarnings =False;- this does not work.
I do not see any default setting within my ODBC connection that I can update to resolve this error.
What command can I include in my pass-through query to resolve this error, execute this job, and complete my task?
ASKER
gustav,
Not sure what you mean.
I run this command from the SQL window and it executes. It is just running it from Access that gives the error.
Not sure what you mean.
I run this command from the SQL window and it executes. It is just running it from Access that gives the error.
I don't know. You have:
> .. ReturnsRecords property set to True
But:
sp_start_job N'Upload_Book_Titles'
doesn't look like it is returning records.
/gustav
> .. ReturnsRecords property set to True
But:
sp_start_job N'Upload_Book_Titles'
doesn't look like it is returning records.
/gustav
ASKER
Ok- I understand your comment now.
The job that the Access app is calling inserts records from an Excel spreadsheet into the SQL table. So, technically, the query is not returning any records back to the Access app - the customer requirement is to insert records from the spreadsheet into the SQL table.
Is there a command I can use to turn off this error message?
The job that the Access app is calling inserts records from an Excel spreadsheet into the SQL table. So, technically, the query is not returning any records back to the Access app - the customer requirement is to insert records from the spreadsheet into the SQL table.
Is there a command I can use to turn off this error message?
OK, but "returns records" in this context is relative to Access.
So I would try running it with ReturnsRecords property set to False.
/gustav
So I would try running it with ReturnsRecords property set to False.
/gustav
ASKER
How would I do that?
I tried DoCmd.SetWarnings False and that did not work.
I tried DoCmd.SetWarnings False and that did not work.
1. Open the query in designview.
2. Set property ReturnsRecords to False
3. Save and close the query.
/gustav
2. Set property ReturnsRecords to False
3. Save and close the query.
/gustav
ASKER
I now get an error - "Incorrect syntax near ReturnRecords"
My code:
SET NoCount ON ;
EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';
ReturnsRecords = False;
My code:
SET NoCount ON ;
EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';
ReturnsRecords = False;
Yes. It is not an SQL statement.
It is in the property sheet of the query in Access this setting exists.
/gustav
It is in the property sheet of the query in Access this setting exists.
/gustav
ASKER
ok - thanks.
I will create a separate function for this.
I thought there was a way to test the pass-through query by running it from the access query list.
I will create a separate function for this.
I thought there was a way to test the pass-through query by running it from the access query list.
There is. You just double-click it and it will run.
/gustav
/gustav
ASKER
When I double click the pass through query, I get the error I included in this incident.
But did you change the property?
/gustav
/gustav
ASKER
I am creating a function to include the other logic you recommended and change the property.
Did I misunderstand your recommendation?
Did I misunderstand your recommendation?
I think so. No code involved, just setting the property of the query.
/gustav
/gustav
ASKER
Confused.
This is how my pass-through query looks from the SQL view on MSAccess:
SET NoCount ON ;
EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';
When I try to run this from MSAccess, it asks for the password (which I enter) then I get the error.
when I include a line to set the ReturnsRecords = False, I still get an error.
Do I need to include something other than "ReturnRecords = False"?
This is how my pass-through query looks from the SQL view on MSAccess:
SET NoCount ON ;
EXEC msdb.dbo.sp_start_job N'Upload_Book_Titles';
When I try to run this from MSAccess, it asks for the password (which I enter) then I get the error.
when I include a line to set the ReturnsRecords = False, I still get an error.
Do I need to include something other than "ReturnRecords = False"?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I understand.
Thank you for your patience and for your help. That resolved the issue. I was able to execute the SQL job from my Access application.
I am now working on my customer being able to execute this pass-through query using a button that will connect to the SQL database via ODBC connection, log in with the password, and complete the task.
Thank you again!!!
Thank you for your patience and for your help. That resolved the issue. I was able to execute the SQL job from my Access application.
I am now working on my customer being able to execute this pass-through query using a button that will connect to the SQL database via ODBC connection, log in with the password, and complete the task.
Thank you again!!!
You are welcome!
/gustav
/gustav
/gustav