[mapserver-users] SQL Server 2008 layer C# MapScript query help

Willem Swanepoel will.swan at ymail.com
Fri Jan 22 00:30:18 EST 2010

I'm just starting out with MapServer / MapScript C#.

I get "Attempted to read or write protected memory" when trying to retrieve
the shape of the selection in a SQL Server layer. Code snippet below
(adapted from example code):

    if (layer.queryByPoint(Map, point, mapscript.MS_SINGLE, tolerance) ==
                        resultCacheObj result = layer.getResults();
                        if (result.numresults > 0)
                        {   int shapeInd =
                            shapeObj shape = layer.getFeature(shapeInd, -1);
<<--Attempted to read or write protected memory

    string txt = "";

    for (int i = 0; i < shape.numvalues;i++)// layer.numitems; i++)
                               txt += "<b>"+ layer.getItem(i) +": </b>";
                                txt += " " + shape.getValue(i) +
                            }  etc.

Additional notes:
* the tolerance > 0
* IIS 5
* using latest build (MSVC2008 (Win32) -stable
release-1500-gdal-1-6-mapserver-5-6.zip) DLLs (including
* VS 2008 project
* the SQL Server layer geometry is points & draws without problems
* code works for other layers in may map

Additional issue:
When doing a queryByShape on the SQL Server layer and try drawQuery on the
map I get "Image handling error. Failed to draw layer..."

Am doing something wrong - is this the correct way of going about querying &
visualizing? Is what I trying to do possible with SQL Server layers?
Any help/pointers appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100122/22d4e30f/attachment.html

More information about the mapserver-users mailing list