Solved

sql

Posted on 2002-07-26
6
140 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

910 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

20 Experts available now in Live!

Get 1:1 Help Now