Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql

Posted on 2002-07-26
6
Medium Priority
?
146 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
Independent Software Vendors: 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 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