Refreshing a prodataset

Posted by Roger Blanchard on 11-Feb-2009 07:33

I am attempting to add a refresh methos to a form that contains an ultraGrid. The probinding source is bound to a prodaset and I can see my records in the ultraGrid. I have added a button to refresh the records from the database with the following code:

bindingSource1:HANDLE= ?.

hBuffer:ATTACH-DATA-SOURCE (hDataSource).

hDataset:FILL-MODE = 'EMPTY'.

hDataset:FILL NO-ERROR.

hBuffer:DETACH-DATA-SOURCE().

bindingSource1:HANDLE = hDataset.

Everything works until I get to the last line where I bind the bindingsource1 to the prodataset. I get the error "No record is available (91)" over and over. It appears I get the error for the number of records in the prodataset.

I will get the same error if I simply EMPTY the prodataset as well.

Does anyone have any ideas?

All Replies

Posted by Admin on 11-Feb-2009 12:10

Roger,

I had the same issue and was able to correct it by essentially clearing the dataset's query. I think it's because the grid still thinks you have records in the bindingsource.

You could try something like:

DEFINE VARIABLE queryHandle AS HANDLE NO-UNDO.

DEFINE VARIABLE hTtHandle AS HANDLE NO-UNDO.

hDataset:EMPTY-DATASET NO-ERROR.

queryHandle = hDataset:TOP-NAV-QUERY(1).

hTtHandle = hDataset:GET-TOP-BUFFER(1):TABLE-HANDLE.

queryHandle:QUERY-PREPARE("preselect each " + hTtHandle:Name).

queryHandle:QUERY-OPEN().

JL

Posted by Roger Blanchard on 11-Feb-2009 12:29

Jim,

That was exactly it!!!! Thanks a bunch.

Posted by Admin on 11-Feb-2009 12:42

You're welcome...glad it worked!

Posted by Peter Judge on 11-Feb-2009 13:38

Roger,

I had the same issue and was able to correct it by

essentially clearing the dataset's query. I think

it's because the grid still thinks you have records

in the bindingsource.

You could try something like:

DEFINE VARIABLE queryHandle AS HANDLE NO-UNDO.

DEFINE VARIABLE hTtHandle AS HANDLE NO-UNDO.

hDataset:EMPTY-DATASET NO-ERROR.

queryHandle = hDataset:TOP-NAV-QUERY(1).

hTtHandle =

hDataset:GET-TOP-BUFFER(1):TABLE-HANDLE.

queryHandle:QUERY-PREPARE("preselect each " +

hTtHandle:Name).

queryHandle:QUERY-OPEN().

If you're using the PDS "as-is", you can also just reopen the hDataset:TOP-NAV-QUERY, instead of doing all of that other stuff.

Just using

might be enough.

You can use the top-nav-query without the ordinal since a binding source only likes datasets with 1 top-level table.

-- peter

This thread is closed