問題描述
基本上我是通過運行時檢索程序中的所有數據,我想知道如何檢索更新后受影響的行數,以便我可以通過 VB.NET 提示用戶有關它
Basically I'm retrieving all the data in my program through runtime, I was wondering how will I retrieve the number of rows affected after an update so I could prompt the user about it through VB.NET
我實際做的是,更新后,如果沒有其他行更新,則用戶無法再點擊按鈕
What I'm actually doing is, after an update, if there are no other rows updated then the user can no longer click on the button
推薦答案
通過使用 ExecuteNonQuery,它將不返回任何行,任何輸出參數或映射到參數的返回值都填充了數據.
By using ExecuteNonQuery, it will returns no rows, any output parameters or return values mapped to parameters are populated with data.
對于 UPDATE、INSERT 和 DELETE 語句,返回值是受命令影響的行數.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command.
您可以像這樣提示用戶
Dim RowsAffected as Integer = Command.ExecuteNonQuery()
MsgBox("The no.of rows effected by update query are " & RowsAffected.ToString)
這篇關于如何檢索從 SQL Server 影響到 VB.NET 的行數?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!