Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Only error? 1

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I have a TDatabase with the ReadOnly property = False.
I have a TQuery (with no joins) with RequestLive = True and Unidirection = False with a datasource with the AutoEdit property = True.

However, when I try to put the datasource into an Edit or insert state, I get an error:

"Cannot modify a read-only dataset."

Can someone please let me know where else I should look to figure out why it thinks the dataset is read only?

Thanks!

Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
I have no idea. Some of the posts below mention cached updates being set to true might help.

The following was copied from several posts in the borland.public.delphi.database group.

//--------------------------------
If you use heterogeneous joins and queries executed against Paradox or dBase files, these are parsed by the BDE using local SQL. In local SQL you CANNOT obtain a live result set if you use:
* DISCTINCT in the select clause
* Joins
* Aggregate functions
* Subqueries
* ORDER BY clauses not bases on an index

For remote server SQL you CANNOT obtain a live result if you use:
* DISCTINCT in the select clause
* Aggregate functions
* Joins (References to more tan one base table or updatable view, the
Developers Guide states).
* Subqueries that reference the table in the FROM clause.

Setting CachedUpdates to True is not enough. You also need to set either the TQuery.UpdateObject or provide a handler for TQuery.OnUpdateRecord. If you have no intention of saving the changes with either method, you can provide an empty OnUpdateRecord handler just to make Delphi happy.

//--------------------------------
Are you trying to sort the query? Reading the google groups seems to indicate that there are difficulties with this.

See the local SQL online help (LOCALSQL.HLP, found in the main BDE directory). In the index, search for "updatable queries" for information on when result sets will be read-only (which includes use of an ORDER BY clause) and when this can (and when it cannot) be overcome using an index.
//--------------------------------

I'm no expert but I encountered a similar problem when I was building SQL statements at runtime to access an AS/400 server via ODBC. The crunch came when a statement was built that could not be processed by BDE Local SQL. For instance I found using wildcards WHERE FLD = '%ABC%' caused such an exception. However I found I could monitor for it and continue to open the table read only

//--------------------------------

Make sure your SQL table & column names are in UPPER CASE if RequestLive is true.

//--------------------------------

If you are running against dBASE or Paradox, then you won't get a live result set with Order By unless the Order By is based on an index. I guess you have two options: Add an Index on the column(s) you're ordering by, or used cached Updates instead of Request Live.

//--------------------------------

Try checking the canModify property of the query. It should be true if requestLive succeeded If it is then there is something else wrong with your code.

//------These two are Interbase issues----------------
If you have set the ResolveToDataset to true you will have to add an IBUpdateSQL. IBQuery is a read only component.

Two things can cause this message. First is no ModifySQL statement. The second is insufficient rights to update the underlying table.
//------These two are Interbase issues---------------- Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
Brian - You Rock!!!

It was my Order by clause that was causing the problem. Thanks for the info!

Les
Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Do a debug, and see if the ReadOnly property is set to true or false when you try and put the datasource into an Edit or insert state.

If it is true, then it was changed somewhere else. If not, I guess youa re back at square one...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top