Sql server does not show the map

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.

  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

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

In the documentation of AddLayerFromDatabase() a code snippet is shown to get the shapefile object using GetBuffer(). Can you try that and check if the shapefile has any shapes?

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

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 but it doesn’t seems to be a common projection. You need to find the EPSG code first, then create a new GeoProjection and assign it to the map.

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:

//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.

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…

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 or use MapWinGIS’ GdalVectorTranslate() which is doing the same as OGR2OGR.