?
Solved

sql

Posted on 2002-07-26
6
Medium Priority
?
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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