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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange problem with a cursor behind a grid

Status
Not open for further replies.

RedLion

Programmer
Joined
Sep 13, 2000
Messages
342
Location
NL
Hello,

I’ve got a form, on it a grid, behind the grid there is a cursor with 4 fields. The grid has 2 textfields (std) within his columns, and one column with a checkbox. When the afterrowcolchange event is triggered there is called a procedure that looks like this:


local nId
select (thisform.myGrid.recordSource)
nId = field1
nId = thisform.oBusiness.getNextValue(nId)
select (thisform.myGrid.recordSource)
replace field4 with nId && Not visible field in the grid, error occurs here


The error occurs here, and in VFP 6.0 SP5 the error is: Cannot update because an user has locked the record

After searched every where on the web and the knowledge base I'm very desperate and tried it with VFP 8.0 and this returned an other error on the same line (statement):
Cursor cannot be modified because it contains an unsaved record.

How can I save the data to the cursor explicit?

Is there anyone who has ever had the same problem?

If there is someone who knows anything to help PLEASE???


Thanks in advance,

Charl
 
How is the cursor generated?
1. A cursor created from a SQL statement is read-only.
2. A cursor created with CREATE CURSOR can be edited.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
with this method:


procedure getData

* get the data in a readonly cursor
local m.lwReadCursor
m.lwReadCursor = sys(2015)
select fielda, fieldb, fieldc, fieldd from tablec into cursor (m.lwReadCursor)

local m.lwWriteCursor
m.lwWriteCursor = sys(2015)

* get the structure from the read cursor
local m.laStructuur
dimension m.laStructuur(1)
select (m.lwReadCursor)
aFields(m.laStructuur)

* write cursor maken
create cursor (m.lwWriteCursor) from array m.laStructuur

* copy the old data from read to write cursor
select * from (m.lwReadCursor) into array laStructuur
if _tally > 0
select (m.lwWriteCursor)
append from array m.laStructuur
endif

* Closing not used cursors
select (m.lwReadCursor)
use

return m.lwWriteCursor

endproc
 
SQL SELECT created cursors are always READONLY by default (as your code notes). But if you have 7/8, then you can just add the READWRITE option to make it updateable - seeming much less complicated that this routine.

It's not clear that the cursor name (m.lwWriteCursor) returned from this routine is the same as the value stored thisform.myGrid.recordSource, especially since there is no field4 in the original SQL SELECT.

Rick
 
Are you resetting your recordsource of your grid to the m.lwWriteCursor?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
But if you have 7/8
That's not a solution, it should be written in 6, but for testing purpose I've tried it with 8.

It's not clear that the cursor name
Yes, I'm sorry, but that is not the problem, the official source consists out of a number of class calling each other and to make it readable I've putted it all in one procedure. (should be field1, field2, field3, field4 in the procedure)

Are you resetting your recordsource of your grid to the m.lwWriteCursor?
Only the grid.init() has the statement:
this.recordsource = thisform.oBusiness.getData() && set the cursor to the grid
The grid recordSourceType = alias, I'm not using buffering


Thanks for your response and time Rick and Mike!


Charl
 
Thanks again for your response Rick and Mike, and I would like to apologise for the worse (wrong) information I submitted with the question. The reason therefore is that the interface with everything behind is build up so complex, that it is very difficult to make an easy readable question with enough information to solve the problem, without over flooding you with pages of code.

After two days spent on the problem I’ve found that it was the checkbox in the grid that is locking up the grid, and causes all error messages. The reason that the checkbox is doing that is still a question for me, because the only code behind it is a statement that changes the state of a form property when there has an interactiveChange event occurred, so the form knows that there is something that has to be saved before closing the form.


Charl
 
RedLion

Controls other then the default textbox in a grid would most likely need to be reset if your recordsource changes.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top