大家好,又见面了,我是你们的朋友全栈君。
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账号...