TDBXCommand.IsPrepared property always False

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

TDBXCommand.IsPrepared property always False

Post by Eden0928 » Thu 05 Mar 2020 02:33

Hello, I try the SQL Server driver for dbexpress v8.1.3, code is below:

Code: Select all

const DEVART_MSSQL_CONNECTION_STRING = ''
  +'%s=DevartSQLServer;%s=%s;%s=%s;%s=%s;%s=%s'
  +';BlobSize=-1;SchemaOverride=%%.dbo;LongStrings=True;EnableBCD=True'
  +';FetchAll=True;UseUnicode=True;IPVersion=IPv4';

procedure TForm1.Button1Click(Sender: TObject);
var
  cn: TDBXConnection;
  FConnectionProps: TDBXProperties;
  FConnectionFactory: TDBXConnectionFactory;
  cmd: TDBXCommand;
  rer: TDBXReader;
begin
  FConnectionProps := TDBXProperties.Create;
  FConnectionProps.SetProperties(Format(DEVART_MSSQL_CONNECTION_STRING,
                        [TDBXPropertyNames.DriverName,
                         TDBXPropertyNames.HostName, 'localhost',
                         TDBXPropertyNames.Database, 'ADBDEMOS',
                         TDBXPropertyNames.UserName, 'sa',
                         TDBXPropertyNames.Password, 'saps']));
  FConnectionFactory := TDBXConnectionFactory.GetConnectionFactory;
  cn := FConnectionFactory.GetConnection(FConnectionProps);
  cmd := cn.CreateCommand;
  cmd.Text := 'SELECT * FROM employee where empno=:empno';
  cmd.Prepare;
  if cmd.Parameters.Count > 0 then
  begin
    if cmd.IsPrepared then
    begin
      rer := cmd.ExecuteQuery;
      if rer.Next then
        Caption := rer.Values[0].AsString;
      rer.Free;
    end;
  end;
  cmd.Free;
end;
After TDBXCommand.Prepare method, the TDBXCommand.IsPrepared property should Ture.
However I get the False.

Should I how to do?

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: TDBXCommand.IsPrepared property always False

Post by Stellar » Tue 10 Mar 2020 14:07

This behavior is related to the standard class TDBXCommand in dbExpress, we cannot impact it. You may contact Embarcadero about this issue.
You can try using any other standard dbExpress driver -- the behavior will remain the same.

Post Reply