Solved

sql

Posted on 2002-07-26
6
139 Views
Last Modified: 2010-05-02
I have a recordset declared in code and I have a SQL query running for this recordset.
I have returned some results but I need to edit a field in the results.
The system says the recordset is read-only.
How can I make the recordset not read-only so I can update my field??

Thanks
0
Comment
Question by:SCOTT78
  • 2
  • 2
  • 2
6 Comments
 
LVL 5

Expert Comment

by:RainUK
ID: 7179679
I assume in your recordset object you have specified that the recordset is adLockReadonly. Therefore it will not let you update to the database.

Depending on the application you are writing, you need to read about locking mechanisms.

But for the moment just use adLockOptimistic

Give it a try
0
 

Author Comment

by:SCOTT78
ID: 7179706
Hi,

Thanks for that but
I have used LockOptimistic and OpenDynamic but the Object is still Read-Only apparently.

Any other suggestions??
0
 
LVL 5

Expert Comment

by:RainUK
ID: 7179716

The user you have logged on as in SQL, does this user have the right to write to the table you are trying to update?

Also please paste the full error here including error number plz.

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:SCOTT78
ID: 7179737
The user is admin and the rights are readwrite.
The database is Access 2000.

Here is the error message dialog.

Run Time Error '-2147467259(80004005);

[Microsoft][ODBC Microsoft Access Driver] Cannot Update.
Database or Object is read-only.

Thanks
0
 
LVL 17

Expert Comment

by:Barry Cunney
ID: 7179749
SCOTT78
What type of database are you running SQL statement over.
I know in MS Access, sometimes, depending on what your Select statement is doing the returned recordset is read-only.

What I sometimes do, to get a better handle on what my SQL statement is doing is:
1. Construct the SQL statement and store it in a string variable
2. Print this variable in debug window.
3. Copy resulting SQL statement from debug window, and paste into relevant place in database application.

For example in MS Access you can create a new query, go View|SQL and paste SQL Statement in there, run query and see what the state of the resulting recordset is.

...or SQL Server you can paste sql statement into Query Analyzer.


I know I am not directly answering your question but my experience in these problems is that you have to take a piecemeal and scientific approach.

You have to try and manually mimic and run what your code is doing.


 
0
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 50 total points
ID: 7179758
Scott
Just seen your last comment
You are using MS Access
I have seen problems when errors happen as you are developing a vb app and MS Access and it creates a lock comes on database.
In usch cases I have had to reboot PC to get rid of lock.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now