oracle的executereader,OracleCommand.ExecuteReader 方法 (System.Data.OracleClient) | Microsoft Docs...

public:

System::Data::OracleClient::OracleDataReader ^ ExecuteReader(System::Data::CommandBehavior behavior);

public System.Data.OracleClient.OracleDataReader ExecuteReader (System.Data.CommandBehavior behavior);

member this.ExecuteReader : System.Data.CommandBehavior -> System.Data.OracleClient.OracleDataReader

override this.ExecuteReader : System.Data.CommandBehavior -> System.Data.OracleClient.OracleDataReader

Public Function ExecuteReader (behavior As CommandBehavior) As OracleDataReader

参数

返回

示例

下面的示例创建一个 OracleCommand ,然后通过传递一个字符串(一个 SQL SELECT 语句)和一个用于连接到数据库的字符串来执行它。The following example creates an OracleCommand, and then executes it by passing a string that is an SQL SELECT statement, and a string to use to connect to the database.

public void CreateMyOracleDataReader(string queryString, string connectionString)

{

using (OracleConnection connection = new OracleConnection(connectionString))

{

OracleCommand command = new OracleCommand(queryString, connection);

connection.Open();

// Implicitly closes the connection because

// CommandBehavior.CloseConnection is specified.

OracleDataReader reader =

command.ExecuteReader(CommandBehavior.CloseConnection);

while (reader.Read())

{

Console.WriteLine(reader.GetValue(0));

}

reader.Close();

}

}Public Sub CreateMyOracleDataReader(ByVal queryString As String, _

ByVal connectionString As String)

Using connection As New OracleConnection(connectionString)

Dim command As New OracleCommand(queryString, connection)

connection.Open()

'Implicitly closes the connection because

' CommandBehavior.CloseConnectionwas specified.

Dim reader As OracleDataReader = _

command.ExecuteReader(CommandBehavior.CloseConnection)

While reader.Read()

Console.WriteLine(reader.GetValue(0))

End While

reader.Close()

End Using

End Sub

注解

如果希望 SQL 语句仅返回一行,则将指定 SingleRow 为 CommandBehavior 值可以提高应用程序性能。If you expect your SQL statement to return only a single row, specifying SingleRow as the CommandBehavior value may improve application performance.

当 CommandType 属性设置为时 StoredProcedure ,应将 CommandText 属性设置为存储过程的名称。When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. 然后,在调用时,该命令将执行此存储过程 ExecuteReader 。The command then executes this stored procedure when you call ExecuteReader.

OracleDataReader支持一种特殊模式,该模式允许有效读取较大的二进制值。The OracleDataReader supports a special mode that enables large binary values to be read efficiently. 有关详细信息,请参阅的 SequentialAccess 设置 CommandBehavior 。For more information, see the SequentialAccess setting for CommandBehavior.

OracleDataReader在任意给定时间,都可以打开多个。More than one OracleDataReader can be open at any given time.

适用于

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值