473,422 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

Can't execute UPDATE SPROC from code - Error 3065

My client has recently upsized to a SQL Server back end. All is fine
except there is an UPDATE query that is very slow. I've tested it in
SQL Server and it runs fine, so I'd like to execute a SQL Server
Stored Procedure from the Access application in code. The way I've
done it is to "EXEC" the SPROC from within a pass-through query.
However, when I run it I get an Error 3065 "Cannot execute a select
query".

The code is as follows:

Dim qdfPT As DAO.QueryDef

Set qdfPT = CurrentDb.QueryDefs("qryUpdateCostOfBookingPT")
qdfPT.Execute <--- Error thrown here
qdfPT.Close
Set qdfPT = Nothing

The query qryUpdateCostOfBookingPT is:

EXEC "qryUpdateCostOfBooking"

The SPROC is:

CREATE PROCEDURE qryUpdateCostOfBooking AS

BEGIN

UPDATE
tblAccounts
SET
tblAccounts.[BOOKING TOTAL] = tblBookings.TOTAL
FROM
tblbookings LEFT JOIN
tblAccounts ON tblbookings.BookingID=tblAccounts.BookingID
END
GO
Jul 24 '08 #1
2 4124
Try this:

qdfPT.ReturnsRecords = False

Also, lose the inverted commas around the SP name i.e.

EXEC qryUpdateCostOfBooking

<te********@hotmail.comwrote in message
news:17**********************************@f36g2000 hsa.googlegroups.com...
My client has recently upsized to a SQL Server back end. All is fine
except there is an UPDATE query that is very slow. I've tested it in
SQL Server and it runs fine, so I'd like to execute a SQL Server
Stored Procedure from the Access application in code. The way I've
done it is to "EXEC" the SPROC from within a pass-through query.
However, when I run it I get an Error 3065 "Cannot execute a select
query".

The code is as follows:

Dim qdfPT As DAO.QueryDef

Set qdfPT = CurrentDb.QueryDefs("qryUpdateCostOfBookingPT")
qdfPT.Execute <--- Error thrown here
qdfPT.Close
Set qdfPT = Nothing

The query qryUpdateCostOfBookingPT is:

EXEC "qryUpdateCostOfBooking"

The SPROC is:

CREATE PROCEDURE qryUpdateCostOfBooking AS

BEGIN

UPDATE
tblAccounts
SET
tblAccounts.[BOOKING TOTAL] = tblBookings.TOTAL
FROM
tblbookings LEFT JOIN
tblAccounts ON tblbookings.BookingID=tblAccounts.BookingID
END
GO

Jul 24 '08 #2
On 24 Jul, 12:13, "bcap" <b...@nospam.nowherewrote:
Try this:

qdfPT.ReturnsRecords = False

Also, lose the inverted commas around the SP name i.e.

EXEC qryUpdateCostOfBooking
Marvellous! Thanks for the help.

Edward
Jul 24 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: Mountain Bikn' Guy | last post by:
Take some standard code such as shown below. It simply loops to add up a series of terms and it produces the correct result. // sum numbers with a loop public int DoSumLooping(int iterations) {...
2
by: Tracey | last post by:
Sorry for the repeated post. I tried to update a record in database using SqlCommand.ExecuteNonQuery( ) method (I failed using SqlDataAdapter). I traced the above statement and found that it returned...
2
by: rooster575 | last post by:
Im running a querystring in vb.net and it seems as though SQL server decides on the order in which to run the 3 queries in the string.. Is this possible? I would think that SQL server starts with...
7
by: Mike L. | last post by:
Hi, I got this 'EXECUTE permission denied on object <mySproc>' error message everytime I try executing my SQL server Sproc. What's this and how to fix this err? many thnaks in advance, mike
6
by: Roy | last post by:
Hey all, I'm a relative newcomer to asp.net and have 2 simple code snippets below. Everything works fine, I'm just curious if there is a more efficient way to do the job as the update takes quite a...
4
by: ad | last post by:
I found an example in Starter kit. Is it so tedious to update a record. ---------------------------------------------------------------------------- ------------- SqlConnection myConnection...
21
by: Trint Smith | last post by:
This will be a customer number that is automatically assigned. I want it to be fast (so that it doesn't have to be checked for existance in sql server) and impossible to ever reoccure. Could it...
3
by: teddysnips | last post by:
I'm trying to use the SPROC below (courtesy of Erland!) to capture the error message but it fails owing to insufficient permissions (I can't reproduce it just now, but I think it's because it can't...
2
by: jbonifacejr | last post by:
Sorry if this angers anyone. I'm posting here and to the .NET group. I am unable to get a return value from a stored procedure in .NET using the following Sproc and .NET code Here is the code...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.