User transaction is alredy in progress
Posted: Fri 06 Oct 2006 08:44
Hello
I have a problem, ther i get this error msg: User transaction is alredy in progress
I have a Stringlist with Sql, Inserts and updates and ig run this code:
Function Tzdb.SendSQLExec(SQL:String):boolean;
var
SQLList:TstringList;
fnr:integer;
begin
if(GlobalDebug)Then SQLLOG(SQL);
if(Trim(SQL) = '')then Exit;
Try
SQLList:=TstringList.Create;
Try
CheckConnectionAndFixit;// Connect again if timeout
SQLList.Text:=Trim(SQL);
Result:=True;
MyConnection1.StartTransaction;
For fnr:=0 to SQLList.Count-1 do
begin
MyQuery1.Close;
MyQuery1.SQL.Text:=Trim(SQLList.Strings[fnr]);
MyQuery1.Execute;
end;
MyConnection1.Commit;
Except
Result:=False;
end;
finally
SQLList.Free;
end;
end;
Is this wrong? Is it any way to do this bether? I want to rollback if any sql fails.
Stians.
I have a problem, ther i get this error msg: User transaction is alredy in progress
I have a Stringlist with Sql, Inserts and updates and ig run this code:
Function Tzdb.SendSQLExec(SQL:String):boolean;
var
SQLList:TstringList;
fnr:integer;
begin
if(GlobalDebug)Then SQLLOG(SQL);
if(Trim(SQL) = '')then Exit;
Try
SQLList:=TstringList.Create;
Try
CheckConnectionAndFixit;// Connect again if timeout
SQLList.Text:=Trim(SQL);
Result:=True;
MyConnection1.StartTransaction;
For fnr:=0 to SQLList.Count-1 do
begin
MyQuery1.Close;
MyQuery1.SQL.Text:=Trim(SQLList.Strings[fnr]);
MyQuery1.Execute;
end;
MyConnection1.Commit;
Except
Result:=False;
end;
finally
SQLList.Free;
end;
end;
Is this wrong? Is it any way to do this bether? I want to rollback if any sql fails.
Stians.