Commands out of sync; you can't run this command now
- Details
- Category: dbExpress
- Published on Thursday, 25 November 2010 07:57
- Hits: 355
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
- Category: dbExpress
- Published on Thursday, 16 September 2010 08:26
- Hits: 485
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
PChar vs Pointer.
- Details
- Category: dbExpress
- Published on Monday, 17 November 2008 11:30
- Hits: 474
MySQL
- Details
- Category: dbExpress
- Published on Thursday, 05 November 2009 10:33
- Hits: 521
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'
Exception handling
- Details
- Category: dbExpress
- Published on Friday, 08 August 2008 07:51
- Hits: 785
Problem with dbExpress is that it does not raise an exception if anything is wrong in database (for example, if you try to add primary key which already exist). So, to get an exception, best would be to use OnReconcileError in TClientDataSet... Small example:
procedure Tdm.cdsReconcileError(DataSet: TCustomClientDataSet;
E: EReconcileError; UpdateKind: TUpdateKind; var Action: TReconcileAction);
begin
ShowMessage(e.Message);
end;

