IsDBNullAsync(int, CancellationToken)

This method returns a Task-based asynchronous version of OracleDataReader.IsDBNull(int32).

Declaration

// C#
public override Task<bool> IsDBNullAsync(int index, CancellationToken cancellationToken);

Parameter

  • index - The zero-based column index

  • cancellationToken - The input cancellation token which can be used by the application to cancel the task before command timeout occurs

Return Value

Task<bool> object representing the asynchronous operation immediately without blocking the calling thread for the whole duration of the query execution

Implements

DbDataReader

Exceptions

InvalidOperationException - The reader is closed, Read() has not been called, or all rows have been read.

IndexOutOfRangeException - The column index is invalid.

Example

using Oracle.ManagedDataAccess.Client;
using System;
using System.Data;
using System.Threading;

namespace AsyncApp
{
  class AsyncDemo
  {
    static async Task Main()
    {
      string connectionString = "User Id=HR; Password=<PASSWORD>; Data Source=oracle;";
      OracleConnection oc = new OracleConnection(connectionString);
      await oc.OpenAsync(CancellationToken.None);

      OracleCommand cmd = oc.CreateCommand();
      cmd.CommandText = "select * from demo_table";

      OracleDataReader reader;

      reader = await cmd.ExecuteReaderAsync();
      while (await reader.ReadAsync(CancellationToken.None))
      {
        if(!(await reader.IsDBNullAsync(0)))
        Console.WriteLine(reader.GetValue(0));
      }
    }
  }
}