TUniQuery and TUniconnection
Posted: Thu 23 May 2013 12:03
hello,
I have used Uniconnection and a Uniquery to insert data,if all data be inserted successful then I run uniquery.applyupdates but error occur "Cannot perform this operation on closed dataset" ... whats wrong with this code? thanks a lot..
try
UniConnection.StartTransaction;
UNiquery.Close;
UNiquery.sql.Clear;
UNiquery.SQL.Add('INSERT INTO "TEST" ("VALUE1","VALUE2") ');
UNIQUERY.SQL.Add('VALUES (:p0 ,:p1) ');
FOR I := 1 TO 10
begin
UNIQUERY.Prepare;
UNIQUERY.ParamByName('p0').value := I;
UNIQUERY.ParamByName('p1').VALUE := I;
UNIQUERY.ExecSQL;
end;
UNIQUERY.APPLYUPDATES;
UniConNECT.Commit; // if there were no errors, commit transaction
except
// calling ApplyUpdates
UNIQUERY.RestoreUpdates;
UniConNECTION.Rollback; // roll back transaction
end;
I have used Uniconnection and a Uniquery to insert data,if all data be inserted successful then I run uniquery.applyupdates but error occur "Cannot perform this operation on closed dataset" ... whats wrong with this code? thanks a lot..
try
UniConnection.StartTransaction;
UNiquery.Close;
UNiquery.sql.Clear;
UNiquery.SQL.Add('INSERT INTO "TEST" ("VALUE1","VALUE2") ');
UNIQUERY.SQL.Add('VALUES (:p0 ,:p1) ');
FOR I := 1 TO 10
begin
UNIQUERY.Prepare;
UNIQUERY.ParamByName('p0').value := I;
UNIQUERY.ParamByName('p1').VALUE := I;
UNIQUERY.ExecSQL;
end;
UNIQUERY.APPLYUPDATES;
UniConNECT.Commit; // if there were no errors, commit transaction
except
// calling ApplyUpdates
UNIQUERY.RestoreUpdates;
UniConNECTION.Rollback; // roll back transaction
end;