0

I'm working with Delphi 10.4, ADO, SQL Server, using spatial features (SQL Server spatial ).

Reading the text from the database is based on this code:

    type TDatabaserecord = record 
              ...
              NameStr : String;
              OutLineStr : String;
              ...
         end;
    type TTabRecordList = class(TList<TDatabaserecord>)

         private
         ...
         public
         procedure SavetoFile(Filename: String);

         end;

        procedure ReadDBConent ( ....., MYDatabaserecord : TDatabaserecord );
        begin
             ....
             MyDatabaserecord.NameStr := Fieldbyname('Name').AsString;
             MyDatabaserecord.OutLineStr := Fieldbyname('Geom').AsString;
             ...
        
        end;
        
        procedure  TTabRecordList.SaveDBConent ( ..... );
        var
          i: Integer;
          ds: TDatabaserecord;
          Content: TStringlist;
        begin
          Content := TStringlist.create;
          try
        
            for i := 0 to self.Count - 1 do
            begin
              ds := self.Items[i];
              ...
              ...
              Content.add('Name=' + ds.NameStr);
              Content.add('OutLine=' + ds.OutLineStr);
        
            end;
        
            Content.SavetoFile(Filename);
        
          finally
            Content.Free;
          end;
        end;

Running this code twice at different locations in my code, using the same database I get different results

    (pass , getting correct data)
    Name=NameofObject    
    OutLine=POLYGON ((330692534935335 323094130298054, 347882368377054 323094130298054, 347907281179144 319182820370010, 330717447737425 319108081963742, 330692534935335 323094130298054))
    
    (fail, getting wrong char set ???) 
    Name=NameofObject  
    OutLine=       €3þÕW¦ÅBp8犟,úB bM³ÁÈB ]M(Y-úB JHÿÏÈB0Ω1¿øB€È–K>©ÅB`*4Gë¿øB€3þÕW¦ÅBp8犟,úB          ÿÿÿÿ  

Failures is only linked on reading the spatial field 'geom' Question: do I need to specify the char set while reading data from a SQL Server database? How to do this?

Additional Information on table definition , SQL Statement

create table TableName ( Name varchar(50) NULL,                 
...
                         Geom geometry)
Franz
  • 1,883
  • 26
  • 47

0 Answers0