Micro blog about Answer to the Ultimate Question of Life, the Universe, and Everything.
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home
  3. Delphi
  4. dbExpress

Commands out of sync; you can't run this command now

Details
Written by: Stanko Milosev
Category: dbExpress
Published: 25 November 2010
Last Updated: 18 December 2011
Hits: 6311

If you are receiving error: "Commands out of sync; you can't run this command now" in dbExpress / MySQL connection, then check your query, probably it's something wrong...

 

Also, with connection to MySQL you can't do "select" SQL statement inside transaction, for example:

var
  DBXTran: TDBXTransaction;
begin
  sql1.Close;
  sql1.SQL.Clear;
  sql1.SQL.Text := 'select * from table_one';
  sql1.Open;

  cds2.Open;
  try
    DBXTran := connnection1.BeginTransaction;


    cds2.Append;

    cds2.FieldByName('MyField').AsString := 'test';

    cds2.Post;
    cds2.ApplyUpdates(0);
    connnection1.CommitFreeAndNil(DBXTran);
  finally
    connnection1.RollbackIncompleteFreeAndNil(DBXTran);
  end;

Will be ok, while:

var
  DBXTran: TDBXTransaction;
begin
  cds2.Open;
  try
    DBXTran := connnection1.BeginTransaction;

    sql1.Close;
    sql1.SQL.Clear;
    sql1.SQL.Text := 'select * from table_one';
    sql1.Open;

    cds2.Append;

    cds2.FieldByName('MyField').AsString := 'test';

    cds2.Post;
    cds2.ApplyUpdates(0);
    connnection1.CommitFreeAndNil(DBXTran);
  finally
    connnection1.RollbackIncompleteFreeAndNil(DBXTran);
  end;

Will give you the error...

DBX Error - ParameterNotSet

Details
Written by: Stanko Milosev
Category: dbExpress
Published: 16 September 2010
Last Updated: 18 December 2011
Hits: 6228

If you tried something like:

with cds1.Params do
begin
  ParamByName('finish').AsDateTime := now;    
  ParamByName('start').AsDateTime := Now-1;  
end;
cds1.Open

And you received error like: DBX Error - ParameterNotSet then don't use AsDateTime, use AsSQLTimeStamp := DateTimeToSQLTimeStamp(Now-1);, so your code should look like:

with cds1.Params do
begin
  ParamByName('finish').AsSQLTimeStamp := DateTimeToSQLTimeStamp(now);    
  ParamByName('start').AsDateTime := DateTimeToSQLTimeStamp(Now-1);  
end;
cds1.Open

MySQL

Details
Written by: Stanko Milosev
Category: dbExpress
Published: 05 November 2009
Last Updated: 05 November 2009
Hits: 6256

If you added DBXDynalink to your uses list, deployed:

  dbxconnections.ini
  dbxdrivers.ini
  dbexpsda40.dll

Tried everything what is described here.

Then, try also:

  ConnectionName = 'MYSQLCONNECTION'
  DriverName = 'MySQL'
  GetDriverFunc = 'getSQLDriverMYSQL'
  LibraryName = 'dbexpmda.dll'
  VendorLib = 'libmysql.dll'

PChar vs Pointer.

Details
Written by: Stanko Milosev
Category: dbExpress
Published: 17 November 2008
Last Updated: 30 November -0001
Hits: 5769
If you use FillChar on a variable which is type of PChar, you will loose pointer, and FreeMem will not work.
  1. Exception handling

Page 1 of 2

  • 1
  • 2