>Hi,
> I am working with the grid and populating the grid with a cursor. But i found that the cursor only can be read only when i try to update the fields.
> When i use SQL statement to select some needed fields into cursor to display on grid, i wish to add in new records into the grid(cursor), but it show me the error that the fields is read only. So, i am change to Select Into table, then it allow me to update and add records.
> Is it posible to make it read/write ? how ?
> And whats different if i use cursor and table ?
> thanks
>
>regard,
>kengwen
Chang,
1) To make a cursor readwrite first you should make it a true cursor. In VFP 'nofilter' clause lets you create a true cursor (prior versions need having a nonexistant field or expression forcing it like '..where .t. ...') :
select ... from myTbale into cursor Temp NOFILTER
use dbf('temp') in 0 again alias crsRW
use in 'temp'
select crsRW
2) Actually answer is hidden in your question :) Select into a table.
It's not true that a cursor is kept in memory and table is written to disk. Both are written to disk (even if the cursor just have 1 record with 1 logical field). A cursor is volatile because as you close it VFP does the cleanup for you and that's the difference. If cleanup is not a much concern for you than use a table.
Another difference, in normal circumstances you might think of cursors as tables belonging to a session only. Think of this, in 2 private datasessions you select into cursor 'myCursor'. The 2 myCursor are different because their actual tablenames on disk are generated uniquely (that's what dbf('myCursor') returns). One session cannot access the data in other session unless session is changed or actual name is provided.
Actual disk files being generated uniquely means that if you'd use table then you should also generate a unique name (lcTable=sys(2015)+'.tmp' for example). Otherwise in a multiuser app you'd get into trouble (or multipl data sessions).
You could do so with a strategy like this :
this.tag = sys(2015)
select ... into table (this.Tag)
index on ....
this.RecordSource = (this.Tag)
use in (this.tag)
erase (this.tag+'.*')
Cetin