"TrimFixedChar" only works with Char Type?

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Eden0928
Posts: 60
Joined: Sun 22 Apr 2012 14:08

"TrimFixedChar" only works with Char Type?

Post by Eden0928 » Fri 13 May 2022 07:42

I tested using four literal types: varchar, char, nvarchar, nchar, dfm and code as below:

dfm :

Code: Select all

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 299
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object DBGrid1: TDBGrid
    Left = 176
    Top = 91
    Width = 320
    Height = 120
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'Tahoma'
    TitleFont.Style = []
  end
  object SQLConnection1: TSQLConnection
    ConnectionName = 'DEVART SQL SERVER DIRECT'
    DriverName = 'DevartSQLServerDirect'
    GetDriverFunc = 'getSQLDriverSQLServerDirect'
    LibraryName = 'dbexpsda40.dll'
    LoginPrompt = False
    Params.Strings = (
      'BlobSize=-1'
      'HostName=.\SQLEXPRESS'
      'DataBase=ADBDEMOS'
      'DriverName=DevartSQLServerDirect'
      'User_Name='
      'Password='
      'LongStrings=True'
      'EnableBCD=True'
      'FetchAll=True'
      'TrimFixedChar=True')
    VendorLib = 'not used'
    Connected = True
    Left = 128
    Top = 72
  end
  object SQLQuery1: TSQLQuery
    MaxBlobSize = -1
    Params = <>
    SQL.Strings = (
      
        'select '#39'hi '#39' as VarChar, CAST('#39'hi '#39' AS CHAR(3)) AS Char, Cast('#39'h' +
        'i '#39' as nvarchar(3)) as NVarChar, CAST('#39'hi '#39' AS NCHAR(3)) AS NCha' +
        'r')
    SQLConnection = SQLConnection1
    Left = 136
    Top = 128
  end
  object DataSetProvider1: TDataSetProvider
    DataSet = SQLQuery1
    Left = 296
    Top = 88
  end
  object DataSource1: TDataSource
    DataSet = ClientDataSet1
    Left = 368
    Top = 96
  end
  object ClientDataSet1: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'DataSetProvider1'
    Left = 312
    Top = 152
  end
end
Unit Code :

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBXDevartSQLServer, FMTBcd, DB, StdCtrls, Mask, DBCtrls, DBClient,
  Provider, SqlExpr, Grids, DBGrids;

type
  TForm1 = class(TForm)
    SQLConnection1: TSQLConnection;
    SQLQuery1: TSQLQuery;
    DataSetProvider1: TDataSetProvider;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    ClientDataSet1: TClientDataSet;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  ClientDataSet1.Close;
  ClientDataSet1.Open;
end;

end.
As you can see, only Char and NChar trailing spaces are trimmed, but varchar and Nvarchar are not.

My environment :
dbx driver for SQL SERVER version 9.1.1
Delphi XE, XE7
Windows 10

Is there a parameter similar to "TrimFixedVarChar" ?

Post Reply