# Sql server does not show the map

**URL:** <https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661>\
**Category:** Uncategorized\
**Created:** [July 23, 2020, 11:33am UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661 "2020-07-23T11:33:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silvio](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@Silvio](https://mapwindow.discourse.group/u/Silvio)\
**Post date:** [July 23, 2020, 11:33am UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/1 "2020-07-23T11:33:36Z")

</div>

Hello,  
sql server access with Delphi using version 4.9.6.1 with the commands below and it worked normally, but stopped showing the map.  
AddLayerFromDatabase does not report errors.

```auto
  conn: = 'MSSQL: server = xxxxxx; database = xxxxx; uid = xxxxx; pwd = xxxxx';
  query: = 'select * from gisadmin.PROPRIEDADES where cod_empresa = 1 and numero =' '7066/04' '';

   id: = Map1.AddLayerFromDatabase (conn, query, True);
   Map1.ShapeLayerFillColor [id]: = clGreen;
   Map1.ShapeLayerLineColor [id]: = clBlack;
   Map1.ShapeLayerLineWidth [id]: = 1.5;
   Map1.Redraw;
   Map1.Refresh;

```

Best regards

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [July 24, 2020, 7:18am UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/2 "2020-07-24T07:18:21Z")

</div>

When you run that query directly on the database, using something like SSMS, you do get results?

In the documentation of [AddLayerFromDatabase()](https://www.mapwindow.org/documentation/mapwingis4.9/group __map__ layer__management.html#ga3672fae9774e0bbb917ab23e13855ebe) a code snippet is shown to get the shapefile object using [GetBuffer()](https://www.mapwindow.org/documentation/mapwingis4.9/class_ogr_layer.html#a1a2ffbbd78168673391a0b1db054ae43). Can you try that and check if the shapefile has any shapes?

---

<div class="post-metadata">

**Author:** ![Silvio](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@Silvio](https://mapwindow.discourse.group/u/Silvio)\
**Post date:** [July 24, 2020, 10:27am UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/3 "2020-07-24T10:27:58Z")

</div>

Hello,  
Thank you for your help.  
running sql on SSMS the query is correct and shows results.  
I use delphi and I don’t have the GetBuffer () command.

I have a table A with WGS1984 coordinates and it works perfectly showing the map.  
I have a table B with coordinates SIRGAS2000 UTM ZONE 22S that does not show the map.  
I think the coordinate is my problem, but I don’t know how to change it in the Map component so that it stays with the SIRGAS2000 coordinate

Best regards

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [July 25, 2020, 3:01pm UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/4 "2020-07-25T15:01:26Z")

</div>

Are you mixing the two layers in one map?  
If so, you shouldn’t. MapWinGIS (as any other GIS) can have only one projection for a map.

What you can do is set the projection of the map before you load the data.  
I searched for [SIRGAS2000](http://epsg.io/?q=SIRGAS2000) but it doesn’t seems to be a common projection. You need to find the EPSG code first, then create a new [GeoProjection](https://www.mapwindow.org/documentation/mapwingis4.9/class_geo_projection.html) and [assign it to the map](https://www.mapwindow.org/documentation/mapwingis4.9/group __map__ coordinates.html#gada7fd1791d6a77216f89f237b55d5761).

---

<div class="post-metadata">

**Author:** ![Silvio](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@Silvio](https://mapwindow.discourse.group/u/Silvio)\
**Post date:** [July 27, 2020, 12:08pm UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/5 "2020-07-27T12:08:02Z")

</div>

Good Morning!  
the table A that I mentioned has the WGS1984 projection and loads normally separately.  
when I try to load table B separately, with SIRGAS 2000 UTM ZONE 22S projection with EPSG code 31982 does not show the map.  
Running sql on the sql server works normally.

The " xxxxx.PROPRIEDADES" table was created in the ArcGis environment with the SIRGAS2000 projection

Here is my code:

```auto
//Brazil
// SRC: FLAT COORDINATE SYSTEMS, UTM PROJECTION // (Datum SIRGAS 2000)
// DATUM: SIRGAS 2000 / UTM zone 22S
// EPSG code: 31982

Map1.GeoProjection.ImportFromEPSG (31982);
conn: = 'MSSQL: server = xxxxxx; database = xxxDB; uid = xxxxxx; pwd = xxx';
query: = 'select * from xxxxx.PROPRIEDADES';
id: = Map1.AddLayerFromDatabase (conn, query, True);
Map1.ShapeLayerFillColor [id]: = clGreen;
Map1.ShapeLayerLineColor [id]: = clBlack;
Map1.ShapeLayerLineWidth [id]: = 1.5;
Map1.Redraw;
Map1.Refresh;

```

Graciously.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [July 28, 2020, 6:16pm UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/6 "2020-07-28T18:16:37Z")

</div>

If you don’t mind, to help figure out what’s going on, try calling

```
ZoomToLayer(0); // presuming it's the only layer and the layerHandle = 0

```

Perhaps the layer is loaded, but is just not where it’s supposed to be…

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [July 31, 2020, 7:58am UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/7 "2020-07-31T07:58:34Z")

</div>

Could you attach small portion of your data as a shapefile?  
I think you can use your SQL Server Management Studio to save as a shapefile.  
Or else you can use GDAL’s OGR: [https://gis.stackexchange.com/questions/278511/export-spatial-data-from-sql-server-to-esri-shapefile](https://gis.stackexchange.com/questions/278511/export-spatial-data-from-sql-server-to-esri-shapefile) or use MapWinGIS’ [GdalVectorTranslate()](https://www.mapwindow.org/documentation/mapwingis4.9/class_gdal_utils.html#adfeb0f1ebfcd629a5c8b05a2dfada8d9) which is doing the same as OGR2OGR.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 3:09pm UTC](https://mapwindow.discourse.group/t/sql-server-does-not-show-the-map/661/8 "2022-01-05T15:09:06Z")

</div>


