473,387 Members | 1,771 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,387 software developers and data experts.

Why is SQL Server recordset read only / non-updatable

Hi,

I'm using VBA in Access 2010 to open a DAO recordset and populate with results from a SQL Server 2008 R2 stored procedure. However, when I try to edit the contents with the '.edit' method I get error 3027 ( Cannot update. Database or object is read-only). Can anyone explain why this is happening and what the solution is? I'm using the following code:-

SQL Server 2008 R2 stored procedure:

Expand|Select|Wrap|Line Numbers
  1. --Parameters
  2.  
  3. @User_ID        AS    INT
  4. ,@Dayfile_Status    AS    INT
  5.  
  6. AS
  7. BEGIN
  8.     SET NOCOUNT ON;
  9.  
  10.     SELECT             Work.*
  11.  
  12.     FROM             Work
  13.  
  14.     WHERE            (Date_Dayfiled_For                    <=    GetDate()
  15.         Or                                    Date_Dayfiled_For Is Null)
  16.     AND                                        Date_Completed    Is Null
  17.     AND            User_ID_FK =    @User_ID
  18.     AND            Help_Needed =    0
  19.     AND                                        Dayfile_Status_ID_FK                =    @Dayfile_Status
  20.  
  21.     ORDER BY        IsNull(Date_Dayfiled_For,N'2099/12/31')
  22.                 ,MPAN_CORE
  23.  
  24. END
  25.  
  26.  
  27. --Access 2010 VBA test script
  28.  
  29. Dim qdfMain As DAO.QueryDef
  30. Dim rsMain As DAO.Recordset
  31.  
  32.  
  33. Set qdfMain = CurrentDb.CreateQueryDef("")
  34.  
  35. With qdfMain
  36.     .Connect = CnStr
  37.     .SQL = "EXEC WF.Dayfile_Due " & _
  38.             "@User_ID=1" & _
  39.             ", @Dayfile_Status=1"
  40.     .ReturnsRecords = True
  41.     Set rsMain = .OpenRecordset(dbOpenDynaset, dbSeeChanges)
  42. End With
  43.  
  44. rsMain.Edit
  45. rsMain("User_ID") = 2
  46. rsMain.Update
  47.  
I have update permissions on the table and database in SQL server and the connection string logs me in using 'trusted connection=Yes'. The stored procedure returns the appropriate records which contain records from only one table and that table has a primary key and also a timestamp field so I'm unclear why this would be seen as a read only recordset.

Any help would be greatly appreciated!

Thanks
Aug 26 '15 #1

✓ answered by Seth Schrock

No matter how you are getting the data, using the .Edit method is performing the job on the local PC, not on the server. So this is totally defeating the goal of having everything done on the server while at the same time adding lots of overhead to your program. If you want it to be totally on your server, then you would need to build an UPDATE query as a passthrough query.

8 3398
Seth Schrock
2,965 Expert 2GB
Does your table have a primary key that Access knows about?
Aug 26 '15 #2
jimatqsi
1,271 Expert 1GB
You can execute a stored procedure from Access but I don't believe you can retrieve an updateable recordset from a stored procedure. Stored procedures produce calculated results. It would be like trying to update a recordset that had a column for Sum() or Avg() ... it doesn't make sense.

You could do what you want several ways. One is to simply create a similar stored procedure that accepts parameters and does the update you want to do. Another would be to open an ODBC to the Work table and open the table with the appropriate where criteria. You can also make a pass-through query to do the same thing; the SQL of the Pass-Through query could be modified dynamically as needed.

Not knowing your situation, I can't say which of those, if any, would be the best approach. But I'm pretty sure what you are trying to is not possible.

Jim
Aug 26 '15 #3
Seth: I had assumed when opening the recordset via VBA code that SQL server would have highlighted the primary key field in the returned recordset so Access would work know and work with it but it's the first time I've connected to SQL Server like this so I may be wrong.

Do you know if there is some code that I should use to highlight the primary key field to Access?

Thanks
Aug 26 '15 #4
Seth Schrock
2,965 Expert 2GB
I don't know any code that can do this for a stored procedure. However, if you would create a linked table within Access, Access usually recognizes it (as long as you link to the table and not a view). If it doesn't I do know the code to add it.
Aug 26 '15 #5
Ah Ok, thanks. I'm trying to avoid using linked tables because the queries I will be running are likely to be too complex for Access to send through to SQL Server in one single translated query. I've read that this will result in Access sending the query to SQL Server in several parts and the net result is that SQL Server ends up sending most of the data to the Access front end to do the processing, which defeats my aim of putting the data on the server to avoid network traffic and enable the server to do all the processing.
Aug 26 '15 #6
Seth Schrock
2,965 Expert 2GB
So then you should create a third parameter that stores the new user id and then have the stored proc be a update query instead of a select query. Then all the action is taking place on the server and Access has nothing to do with it other than passing the arguments and telling it to run.
Aug 26 '15 #7
Yes, that makes sense. I think it would be helpful for me to clarify that the way the database is intended to work is as follows:-

1) Select a set of records (New Work, Day file work or Individual item search etc)for the user to work on from the larger set.
2) Feed them one record at a time on an unbound Access form and if they are working on new work then allocate that record to them upon displaying it.
3) Save any changes the user has made to the record when they move from one record to another.
4) Display the total records in their recordset and have a counter of how many records they have worked through so far.

I have already built some tidy code to do this using a DAO recordset/Access back end with linked tables, using the .edit and .update methods to save the changes (in Step 3) so was hoping to just use that same code with the SQL Server recordset, so all record manipulations are done via recordset. I hope that makes a bit more sense now. If I am unable to use the .edit method do you know if running the separate update stored procedure mentioned would automatically and immediately replicate the changes back through to the read only recordset the user is working through in Access (and any other users that have that record present in their recordsets)?
Aug 26 '15 #8
Seth Schrock
2,965 Expert 2GB
No matter how you are getting the data, using the .Edit method is performing the job on the local PC, not on the server. So this is totally defeating the goal of having everything done on the server while at the same time adding lots of overhead to your program. If you want it to be totally on your server, then you would need to build an UPDATE query as a passthrough query.
Aug 26 '15 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Oyvind Ostlund | last post by:
I am trying to read a file online, and was just testing a bit. This is what I tried. -------------------------------------- import sys, httplib showlines = 6 try: servername, filename =...
2
by: Erik | last post by:
I'm using ASP 3.0 and SQL Server 2000. I keep getting this error: a.. Error Type: ADODB.Recordset (0x800A0BB9) Arguments are of the wrong type, are out of acceptable range, or are in conflict...
3
by: Chris | last post by:
Hi, I have two, similar SQL Server 7.0 databases (in the same SQL Server Group) that I use as the backend for two Access 2000 front end applications - one is the live version, the other is the...
8
by: Fred | last post by:
Hello, Our website is currently developed in ASP/Mysql 4. The dedicated servers on which it is currently hosted arrive at saturation. Here is their configuration: - 1 server PIV 2,8Ghz 1GB...
4
by: parez | last post by:
Hi, When does the socket (server) know when to stop reading. e.g. if i have a buffer = 25K and do networkStream.write twice.. what will the server read? 25k or 50K?
0
by: Ontrace | last post by:
hello, I have Problem with Client Server Application when I unplug the client network cable, the server still read the network stream what function should I use to make server detect that the...
7
by: tnjarrett | last post by:
Hello, I have a MS Access continuous subform that was using a query as the recordsource. I changed it to use a recordset instead because when the query was used, the changes to the subform values...
3
sIncognito
by: sIncognito | last post by:
my server is not executing the PHP code what are some specific things I can check to remedy this??? Only the HTML is Showing up in my browser. Thank you. Here is the code (although I don't...
0
by: Aarthi Krish | last post by:
Hi, Is it possible to transfer file from client to server through socket connection with out reading the content of the file ie. directly push the file from one system to another. If possible...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.