473,767 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Query Defs("qryUpdate CostOfBookingPT ")
qdfPT.Execute <--- Error thrown here
qdfPT.Close
Set qdfPT = Nothing

The query qryUpdateCostOf BookingPT is:

EXEC "qryUpdateCostO fBooking"

The SPROC is:

CREATE PROCEDURE qryUpdateCostOf Booking AS

BEGIN

UPDATE
tblAccounts
SET
tblAccounts.[BOOKING TOTAL] = tblBookings.TOT AL
FROM
tblbookings LEFT JOIN
tblAccounts ON tblbookings.Boo kingID=tblAccou nts.BookingID
END
GO
Jul 24 '08 #1
2 4140
Try this:

qdfPT.ReturnsRe cords = False

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

EXEC qryUpdateCostOf Booking

<te********@hot mail.comwrote in message
news:17******** *************** ***********@f36 g2000hsa.google groups.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.Query Defs("qryUpdate CostOfBookingPT ")
qdfPT.Execute <--- Error thrown here
qdfPT.Close
Set qdfPT = Nothing

The query qryUpdateCostOf BookingPT is:

EXEC "qryUpdateCostO fBooking"

The SPROC is:

CREATE PROCEDURE qryUpdateCostOf Booking AS

BEGIN

UPDATE
tblAccounts
SET
tblAccounts.[BOOKING TOTAL] = tblBookings.TOT AL
FROM
tblbookings LEFT JOIN
tblAccounts ON tblbookings.Boo kingID=tblAccou nts.BookingID
END
GO

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

qdfPT.ReturnsRe cords = False

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

EXEC qryUpdateCostOf Booking
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
12305
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) { int result = 0; for(int i = 1;i <=iterations;i++) { result += i;
2
1381
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 1 rows afftected. Then I checked my database, the data was not updated at all Can someone give me a clue ?
2
1445
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 the 1st query, executes it, then goes to the next. For example: ************************************************************ Dim myQueryString as string = _ "INSERT INTO ArchivedClients(ClientNo,ClientName) " & _ "SELECT ClientNo,ClientName...
7
1749
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
1440
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 while. Here's the proc: **************************************** CREATE PROCEDURE @Recon char(10), @Book nvarchar(50), @Van nvarchar(5),
4
1391
by: ad | last post by:
I found an example in Starter kit. Is it so tedious to update a record. ---------------------------------------------------------------------------- ------------- SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings); SqlCommand myCommand = new SqlCommand("Portal_UpdateContact", myConnection);
21
1331
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 be date/hour/minute/second all as one integer? Thanks, Trint .Net programmer trintsmith@hotmail.com
3
1617
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 get access to the DBCC OUTPUTBUFFER). How do I give the SPROC permission to execute? Many thanks Edward
2
1379
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 in my stored proc. set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO
0
9405
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10169
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10013
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9960
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8838
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5424
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3930
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.