开发者

How to check a number of inserted/modified records in TADOCommand?

I am using SQL Server database and after calling a simple SQL script I would like to know how many records were affected by开发者_JS百科 last (or only) executed statement in a script.

I cannot find the reference how to achieve this in Delphi's TADOCommand and I know SQL Server gives this information to provider. I am aware of workarounds like getting @@ROWCOUNT in another query, yet this gives some overhead and unnecessary complexity.

Thanks.


Do you use the

function Execute(var RecordsAffected: Integer; const Parameters: OleVariant): _Recordset; 

version of the Execute method?

From the doc:

RecordsAffected indicates the number of records, if the command operates on data, that are affected by the command after execution.

So that should give you what you need.

Disclaimer: I cannot test this against SQL Server (don't have it).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜