[mapserver-users] MSSQL connection OGR with mapscript
Tamas Szekeres
szekerest at gmail.com
Fri May 23 03:36:22 PDT 2014
Hi,
If you are connecting to a named instance you should use backslash in the
server name of the connection string.
Best regards,
Tamas
2014-05-23 11:56 GMT+02:00 blackcat18 <m18blackcat at hotmail.fr>:
> Hi every one,
>
> I am trying to get data from database using mapscript. whithout
> layer1.status, my output bitmap is blank with a size of 2000*2000.
>
> When I add layer1.status = 1, I get that error :
>
> /An exception of type 'System.ApplicationException' occurred in
> mapscript_csharp.dll but was not handled in user code
> Additional information: msDrawMap(): Image handling error. Failed to draw
> layer named 'GRADIN3'.;msOGRFileOpen(): OGR error. Open failed for OGR
> connection in layer `GRADIN3'.
> Unable to initialize connection to the server for
>
> MSSQL:server=192.168.***.***//SQLSERVER2008;database=OPF_GEO;uid=***;pwd=***;tables=SFP_Siege_CAD(geom),
> [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or
> access denied./
>
> I am connected to to my database with SQL Server Management so the
> connection is ok. May be the connection string is not written correctly.
> How
> can I correct it ?
>
>
> this is my code:
>
> / OSGeo.MapServer.mapObj map = new
> OSGeo.MapServer.mapObj("C://Users//Sweet live//SkyDrive//Projet
> OPENFIELD//MapServer//Programme//WebForm_Map//mapTest.map");
> map.setExtent(18118500, 3877472, 18138000, 3892012);
> map.setSize(2000, 2000);
> // Ge the first layer and set a classification attribute
> OSGeo.MapServer.layerObj layer1 = new
> OSGeo.MapServer.layerObj(map);
> layer1.name = "GRADIN3";
> layer1.type = OSGeo.MapServer.MS_LAYER_TYPE.MS_LAYER_POLYGON;
> //layer1.status = 1;
> //layer1.debug = 1;
> layer1.connectiontype =
> OSGeo.MapServer.MS_CONNECTION_TYPE.MS_OGR;
> layer1.connection =
>
> "MSSQL:server=192.168.***.***//SQLSERVER2008;database=OPF_GEO;uid=***;pwd=***;tables=SFP_Siege_CAD(geom)";
> //layer1.data = "select geom from SFP_Siege_CAD";
> OSGeo.MapServer.classObj classSiege = new
> OSGeo.MapServer.classObj(layer1);
> classSiege.name ="geom";
> OSGeo.MapServer.styleObj styleSiege = new
> OSGeo.MapServer.styleObj(classSiege);
> styleSiege.color.setRGB(125,125,125);
> classSiege.insertStyle(styleSiege,0);
> // map.save("output.map");
> OSGeo.MapServer.imageObj mapimage = map.draw();
> mapimage.save("map.png", map);/
>
> and the output .map:
>
> /MAP
> EXTENT 18118500 3874992 18138000 3894492
> FONTSET "fonts\fonts.list"
> IMAGETYPE "png"
> NAME "MS"
> SIZE 2000 2000
> STATUS ON
> UNITS METERS
>
> OUTPUTFORMAT
> NAME "png"
> MIMETYPE "image/png"
> DRIVER "AGG/PNG"
> EXTENSION "png"
> IMAGEMODE RGB
> TRANSPARENT FALSE
> END # OUTPUTFORMAT
>
> LEGEND
> KEYSIZE 20 10
> KEYSPACING 5 5
> LABEL
> SIZE MEDIUM
> OFFSET 0 0
> SHADOWSIZE 1 1
> TYPE BITMAP
> END # LABEL
> STATUS OFF
> END # LEGEND
>
> QUERYMAP
> SIZE -1 -1
> STATUS OFF
> STYLE HILITE
> END # QUERYMAP
>
> SCALEBAR
> IMAGECOLOR 255 255 255
> INTERVALS 4
> LABEL
> SIZE MEDIUM
> OFFSET 0 0
> SHADOWSIZE 1 1
> TYPE BITMAP
> END # LABEL
> SIZE 200 3
> STATUS OFF
> UNITS MILES
> END # SCALEBAR
>
> WEB
> END # WEB
>
> LAYER
> CONNECTION
>
> "MSSQL:server=192.168.***.***\SQLSERVER2008;database=OPF_GEO;uid=***;pwd=***;tables=SFP_Siege_CAD(geom)"
> CONNECTIONTYPE OGR
> DEBUG ON
> NAME "GRADIN3"
> STATUS ON
> TILEITEM "location"
> TYPE POLYGON
> UNITS METERS
> CLASS
> NAME "geom"
> STYLE
> ANGLE 0
> COLOR 125 125 125
> OFFSET 0 0
> END # STYLE
> STYLE
> ANGLE 0
> COLOR 125 125 125
> OFFSET 0 0
> END # STYLE
> END # CLASS
> END # LAYER
>
> END # MAP/
>
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/MSSQL-connection-OGR-with-mapscript-tp5142084.html
> Sent from the Mapserver - User mailing list archive at Nabble.com.
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140523/771d88f4/attachment.htm>
More information about the MapServer-users
mailing list