How update existing layer from DB?

I’m relatively new to MapWinGIS. So this may be a simple question.

I’m using axMap.AddLayerFromDatabase to add a layer to my map with a query. And it works like a charm.

Now I want to change this existing layer to show the result of another query from the same table in the DB. In other words I just need to modify the query and re-run.

In reality I’m working on a ViewPort-function that activates every time the map bounds change.

But for simplicity let’s work with this example: Let’s say that I query a DB table containing world continents to show only Australia.
Then I select anothor continent - Europe - from a list in my window.
Now I want the same layer to remove Australia and show Europe instead.

How do I do this?

I have tried to use axMap.ReSourceLayer and it removes my first selection alright, but it does not update the layer with new data. Even when I issue a axMap.ReDraw.

Note: I’m working with large quantiies of data (billions of rows). That’s why I need the selection to be done from the DB instead of loading data to RAM a use the internal quering tool.

Regards,

Henrik

Perhaps this is too simplistic, but could you just remove the existing layer and add a new layer based on the new query?

At first I choose to remove and add the layer again.
But it turns out that there is a RedefineQuery() method on the Layer.
That does the trick.

Excellent. Thanks for sharing the solution.