Link to home
Start Free TrialLog in
Avatar of SCOTT78
SCOTT78Flag for United Kingdom of Great Britain and Northern Ireland

asked on

sql

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
Avatar of RainUK
RainUK

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
Avatar of SCOTT78

ASKER

Hi,

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

Any other suggestions??

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.

Avatar of SCOTT78

ASKER

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


 
ASKER CERTIFIED SOLUTION
Avatar of Barry Cunney
Barry Cunney
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial