oracle executesqlcommand,OracleCommand.ExecuteNonQuery 方法 (System.Data.OracleClient) | Microsoft Doc...

针对 Connection 执行 SQL 语句并返回受影响的行数。Executes an SQL statement against the Connection and returns the number of rows affected.

public:

virtual int ExecuteNonQuery();

public:

override int ExecuteNonQuery();

public int ExecuteNonQuery ();

public override int ExecuteNonQuery ();

abstract member ExecuteNonQuery : unit -> int

override this.ExecuteNonQuery : unit -> int

override this.ExecuteNonQuery : unit -> int

Public Function ExecuteNonQuery () As Integer

Public Overrides Function ExecuteNonQuery () As Integer

返回

对于 UPDATE、INSERT 和 DELETE 语句,返回值为该命令所影响的行数。For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. 对于 CREATE TABLE 和 DROP TABLE 语句,返回值为 0。For CREATE TABLE and DROP TABLE statements, the return value is 0. 对于其他所有类型的语句,返回值为 -1。For all other types of statements, the return value is -1.

实现

例外

连接不存在。The connection does not exist.

或-or-

连接未打开。The connection is not open.

示例

The following example creates an OracleCommand and then executes it by using ExecuteNonQuery. 该示例传递了一个字符串,该字符串是 SQL 语句 (如 UPDATE、INSERT 或 DELETE) 以及用于连接数据库的字符串。The example is passed a string that is an SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to connect to the database.

public void CreateOracleCommand(string myExecuteQuery, string connectionString)

{

using (OracleConnection connection = new OracleConnection(connectionString))

{

OracleCommand command = new OracleCommand(myExecuteQuery, connection);

command.Connection.Open();

command.ExecuteNonQuery();

}

}Public Sub CreateOracleCommand(ByVal myExecuteQuery As String, _

ByVal connectionString As String)

Using connection As New OracleConnection(connectionString)

Dim command As New OracleCommand(myExecuteQuery, connection)

command.Connection.Open()

command.ExecuteNonQuery()

End Using

End Sub

注解

您可以使用 ExecuteNonQuery 执行目录操作 (例如,查询数据库的结构或创建) 的表的数据库对象; 或者, DataSet 通过执行 UPDATE、INSERT 或 DELETE 语句来更改数据库中的数据,而无需使用。You can use ExecuteNonQuery to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables); or to change the data in a database, without using a DataSet, by executing UPDATE, INSERT, or DELETE statements.

尽管不 ExecuteNonQuery 会返回任何行,但映射到参数的任何输出参数或返回值都将用数据填充。Although ExecuteNonQuery does not return any 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. 对于 CREATE TABLE 和 DROP TABLE 语句,返回值为 0。For CREATE TABLE and DROP TABLE statements, the return value is 0. 对于其他所有类型的语句,返回值为 -1。For all other types of statements, the return value is -1. 如果发生回滚,则返回值也为-1。If a rollback occurs, the return value is also -1.

适用于

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值