Page 1 of 1

TDBXCommand.IsPrepared property always False

Posted: Thu 05 Mar 2020 02:33
by Eden0928
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?

Re: TDBXCommand.IsPrepared property always False

Posted: Tue 10 Mar 2020 14:07
by Stellar
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.