Skip to content

closing a datasource and table

Forums Forums SIMPOL Programming closing a datasource and table

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #52
    JD Kromkowski
    Participant

    I know this is an elementary question but I can’t seem to find the answer. I am trying to avoid an Error 3. I am testing a very basic modified version of the dataforms example. I want to switch between two different forms. Form A which uses Datasource A and Table A and Form B which uses Datasource B and Table B I start in Form A – everything fine. I switch to Form B – everything fine. I switch back to Form A – Error 3, but the form “loads” I switch back to Form A – Error 3, but the form “loads” I’ve not set the forms up using ppcstype datasource and used the simpolserver so I am presuming this is basically like a share error. So all I’d like to do is close the datasource and the table. f =@ .nul does not aid Shouldn’t I been able to do this without the whole getting involved in the whole application/appframework? I see the function application.closedatasource() in application.sma So I see I need to first close any open tables and then close any open datasources, but I am failing at seeing how I do it. f.mastertable.datasource.remove(what goes here ? and where do I find it in f) f.mastertable.datasource.remove(f.mastertable.datasourcenode) ?

    #1487
    Michael
    Keymaster

    On 22/03/2012 17:07, JDK wrote:
    > I know this is an elementary question but I can't seem to find the answer.
    >
    > I am trying to avoid an Error 3.
    >
    > I am testing a very basic modified version of the dataforms example.
    >
    > I want to switch between two different forms.
    >
    > Form A which uses Datasource A and Table A
    >
    > and
    >
    > Form B which uses Datasource B and Table B
    >
    >
    > I start in Form A – everything fine. I switch to Form B – everything fine.
    >
    > I switch back to Form A – Error 3, but the form "loads" I switch back to Form A – Error 3, but the form "loads"

    The form will load, but warn you that it is not valid for use. You get error 3, because the database container file is already
    open and you still have a reference to that table which is keeping it open.

    > I've not set the forms up using ppcstype datasource and used the simpolserver so I am presuming this is basically like a share
    > error.

    It is. Using PPCS, this doesn't happen, because you do not open the container physically.

    > So all I'd like to do is close the datasource and the table.
    >
    > f =@ .nul does not aid

    I just looked at the code for dataforms.sma and since the open takes place in the main, I am not clear on what you are doing that
    is holding a reference open.

    > Shouldn't I been able to do this without the whole getting involved in the whole application/appframework?

    Sure. Just make sure that you don't have any variable that is still in scope that is holding a reference to anything connected
    with the datasource, including a record, a field, a table, an index, etc.

    > I see the function application.closedatasource() in application.sma
    >
    > So I see I need to first close any open tables and then close any open datasources, but I am failing at seeing how I do it.
    >
    > f.mastertable.datasource.remove(what goes here ? and where do I find it in f)
    >
    > f.mastertable.datasource.remove(f.mastertable.datasourcenode) ?

    The whole point of the application framework is to ensure that you don't need to replicate all of that code. The fact is, the
    application contains a ring of datasources purely because you can't open the same file-based datasource more than once, so to open
    the same table multiple times in different places in your code, you need to be sharing the previously opened database container
    file object.

    Ciao, Neil

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.