Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何检索从SQL Server到VB.NET受影响的行数?_Sql Server_Vb.net - Fatal编程技术网

Sql server 如何检索从SQL Server到VB.NET受影响的行数?

Sql server 如何检索从SQL Server到VB.NET受影响的行数?,sql-server,vb.net,Sql Server,Vb.net,基本上,我通过运行时检索程序中的所有数据,我想知道如何检索更新后受影响的行数,以便通过VB.NET提示用户 我实际上在做的是,在更新之后,如果没有其他行被更新,那么用户不能再使用单击按钮,它将不返回任何行,任何输出参数或映射到参数的返回值都将填充数据 对于UPDATE、INSERT和DELETE语句,返回值是受命令影响的行数 编辑: 您可以像这样提示用户 Dim RowsAffected as Integer = Command.ExecuteNonQuery() MsgBox("The no.

基本上,我通过运行时检索程序中的所有数据,我想知道如何检索更新后受影响的行数,以便通过VB.NET提示用户

我实际上在做的是,在更新之后,如果没有其他行被更新,那么用户不能再使用单击按钮,它将不返回任何行,任何输出参数或映射到参数的返回值都将填充数据

对于UPDATE、INSERT和DELETE语句,返回值是受命令影响的行数

编辑:

您可以像这样提示用户

Dim RowsAffected as Integer = Command.ExecuteNonQuery()
MsgBox("The no.of rows effected by update query are " & RowsAffected.ToString)

如果直接使用SQLCommand对象,则调用ExecuteOnQuery将返回受影响的行数:

Dim I as Integer= MyCommandObject.ExecuteNonQuery()
希望这有意义。

您可以使用:

Dim cmd As SqlCommand
Dim rows_Affected as Integer
rows_Affected = cmd.ExecuteNonQuery()

您可以更新语句以返回rowcount值

这应该是有帮助的