Skip to content

Commit 59191da

Browse files
committed
fix: connect MS SQL query to session transaction, run .ExecSQL
Refs #2149
1 parent af24108 commit 59191da

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

source/dbconnection.pas

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,19 +3761,21 @@ procedure TMySQLConnection.Query(SQL: String; DoStoreResult: Boolean=False; LogC
37613761
procedure TSqlSrvConnection.Query(SQL: String; DoStoreResult: Boolean=False; LogCategory: TDBLogCategory=lcSQL);
37623762
var
37633763
TimerStart: QWord;
3764-
VarRowsAffected: OleVariant;
3765-
QueryResult, NextResult: TSQLQuery;
3766-
Affected: Int64;
3764+
QueryResult: TSQLQuery;
37673765
begin
37683766
inherited;
37693767

37703768
TimerStart := GetTickCount64;
37713769
FLastRawResults.Clear;
37723770
try
3773-
QueryResult := TSQLQuery.Create(FHandle); // FAdoHandle.ConnectionObject.Execute(SQL, VarRowsAffected, 1);
3771+
QueryResult := TSQLQuery.Create(FHandle);
37743772
FLastRawResults.Add(QueryResult);
37753773
QueryResult.DataBase := FHandle;
3774+
QueryResult.Transaction := FTransaction;
37763775
QueryResult.SQL.Text := SQL;
3776+
QueryResult.Options := [sqoAutoApplyUpdates, sqoAutoCommit, sqoCancelUpdatesOnRefresh];
3777+
QueryResult.PacketRecords := 10000;
3778+
QueryResult.ExecSQL;
37773779
Inc(FRowsAffected, QueryResult.RowsAffected);
37783780
FLastQueryDuration := GetTickCount64 - TimerStart;
37793781
FLastQueryNetworkDuration := 0;

0 commit comments

Comments
 (0)