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

oracle的executereader,OracleCommand.ExecuteReader 方法 (System.Data.OracleClient) | Microsoft Docs…public:System::Data::OracleClient::OracleDataReader^ExecuteReader(System::Data::CommandBehaviorbehavior);publicSystem.Data.OracleClient.OracleDataReaderExecuteReader(System.Data.CommandBehavior…

大家好,又见面了,我是你们的朋友全栈君。

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.

适用于

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/151520.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号