You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NET-3859 Fix S6966 FP: ServerConnection.ExecuteNonQuery (SMO) has no async counterpart #9803
Rule S6966 flags ServerConnection.ExecuteNonQuery() from Microsoft SQL Server Management Objects (SMO) with:
Await ExecuteNonQueryAsync instead.
However, ServerConnection.ExecuteNonQuery has no async counterpart. The ServerConnection class (from Microsoft.SqlServer.SqlManagementObjects) does not provide an ExecuteNonQueryAsync method.
The analyzer likely matches the method name against SqlCommand.ExecuteNonQueryAsync from a different class hierarchy (System.Data.SqlClient / Microsoft.Data.SqlClient), but these are unrelated types.
A quick note before we dig in: the linked docs page targets sql-smo-160 (and Microsoft Learn currently defaults to sql-smo-172). However, async overloads of ExecuteNonQuery, ExecuteReader, ExecuteScalar, and ExecuteWithResultswere added to ServerConnection in Microsoft.SqlServer.SqlManagementObjects v181.19.0 (April 2025, ships with SSMS 22):
So whether this is a true FP depends on which SMO version your project references. Could you share the Microsoft.SqlServer.SqlManagementObjects version from your csproj/packages.lock.json?
If you're on >= 181.19.0: the rule is actually correct — there is an ExecuteNonQueryAsync you can await, and the Microsoft Learn page just hasn't caught up.
If you're on < 181.19.0 (e.g. v160/v172): we'll dig into why the analyzer is flagging it despite no async counterpart being present on ServerConnection — that would be a genuine FP and we'll get it fixed.
changed the title [-]Fix S6966 FP: ServerConnection.ExecuteNonQuery (SMO) has no async counterpart[/-][+]NET-3859 Fix S6966 FP: ServerConnection.ExecuteNonQuery (SMO) has no async counterpart[/+]on Jun 3, 2026
Activity
martin-strecker-sonarsource commentedon Jun 3, 2026
Hi @tsimbalar, thanks for the report!
A quick note before we dig in: the linked docs page targets sql-smo-160 (and Microsoft Learn currently defaults to sql-smo-172). However, async overloads of
ExecuteNonQuery,ExecuteReader,ExecuteScalar, andExecuteWithResultswere added toServerConnectioninMicrosoft.SqlServer.SqlManagementObjectsv181.19.0 (April 2025, ships with SSMS 22):main):ServerConnection.cs#L1546—public async Task<int> ExecuteNonQueryAsync(string sqlCommand, CancellationToken cancellationToken = default)So whether this is a true FP depends on which SMO version your project references. Could you share the
Microsoft.SqlServer.SqlManagementObjectsversion from yourcsproj/packages.lock.json?ExecuteNonQueryAsyncyou canawait, and the Microsoft Learn page just hasn't caught up.ServerConnection— that would be a genuine FP and we'll get it fixed.Thanks!
[-]Fix S6966 FP: ServerConnection.ExecuteNonQuery (SMO) has no async counterpart[/-][+]NET-3859 Fix S6966 FP: ServerConnection.ExecuteNonQuery (SMO) has no async counterpart[/+]github-actions commentedon Jun 3, 2026
Internal ticket NET-3859