IsDBNull cannot give me the right result

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
xin_scott
Posts: 3
Joined: Wed 05 Jun 2013 02:40

IsDBNull cannot give me the right result

Post by xin_scott » Wed 05 Jun 2013 02:49

The issue is caused by a simple select statement. Simple code as following below:

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Devart.Data.Oracle;
using System.Data;

namespace ConsoleApplication2
{
  class Program
  {
    static string connString = "user id=yx_trunk_central;server=dev;Unicode=true;password=1122;";
    static void Main(string[] args)
    {
      OracleDataReader _reader;
      OracleCommand _cmd = new OracleCommand();
      

      //clear table
      Excute("delete from MYTABLE");
      ////insert
      Excute("insert into MYTABLE(ID,FLG,ID1,ID2,time,name,time1,X,act,ks,kst,time2,time3,ex,lst,lst1,user2,psid,time4,sts,spsid,status,time5) values('5806C1FF6F02A04AAA9D2AD2260703BB',0,'54DF494826B3A0458A24F65B3FA428D8',2,to_date('2013-06-03','yyyy-mm-dd'),'XXX',to_date('2013-06-03','yyyy-mm-dd'),'63446F95376F3F49BAAC911060210F43','DE3577BEF4A4AC4DBF9DFAC0BADA9F8F','EFCD53F162326B4D87FB0939A1C21D31','81492B95AD6E244BA7ACA80440F5D35C',to_date('2013-06-03','yyyy-mm-dd'),to_date('2013-06-03','yyyy-mm-dd'),null,null,null,null,'F19DB655CBA30F4984F9B4E38DAC8174',to_date('2013-06-03','yyyy-mm-dd'),3,null,null,to_date('2013-06-03','yyyy-mm-dd'))");

      #region select returned false **  it is not right
      _cmd = new OracleCommand();
      
      _cmd.CommandText = "select t0.time1,t0.act,t0.time5,t0.user2,t0.ex,t0.sts,t0.status,t0.ks,t0.ID,t0.X,t0.psid,t0.spsid,t0.lst1,t0.time3,t0.lst,t0.time4,t0.ID1,t0.time2,t0.ID2 from MYTABLE t0";
      Console.WriteLine(_cmd.CommandText);
      _cmd.Connection = new OracleConnection();
      _cmd.Connection.ConnectionString = connString;
      _cmd.Connection.Open();
      _reader = _cmd.ExecuteReader(CommandBehavior.Default);
      if (_reader.Read())
      {
        bool isNull = _reader.IsDBNull(3);
        Console.WriteLine(isNull);
        if (!isNull)
          Console.WriteLine("result:"+_reader.GetString(3));
      }
      _cmd.Connection.Close();
      #endregion

      Console.WriteLine("\n********************************************************************\n");

      #region select returned true **  it is right
      _cmd = new OracleCommand();
      _cmd.CommandText = "select t0.time1,t0.time5,t0.act,t0.user2,t0.ex,t0.sts,t0.status,t0.ks,t0.ID,t0.X,t0.psid,t0.spsid,t0.lst1,t0.time3,t0.lst,t0.time4,t0.ID1,t0.time2,t0.ID2 from MYTABLE t0";
      Console.WriteLine(_cmd.CommandText);
      _cmd.Connection = new OracleConnection();
      _cmd.Connection.ConnectionString = connString;
      _cmd.Connection.Open();
      _reader = _cmd.ExecuteReader(CommandBehavior.Default);
      if (_reader.Read())
      {
        bool isNull = _reader.IsDBNull(3);
        Console.WriteLine(isNull);
        if (!isNull)
          Console.WriteLine("result:" + _reader.GetString(3));
      }
      _cmd.Connection.Close();
      #endregion
    }

    static void Excute(string sql)
    {
      OracleCommand _cmd = new OracleCommand();
      _cmd.CommandText = sql;
      _cmd.Connection = new OracleConnection();
      _cmd.Connection.ConnectionString = connString;
      _cmd.Connection.Open();
      _cmd.ExecuteNonQuery();
      _cmd.Connection.Close();
    }
  }
}
My demo project you can get from https://dl.dropboxusercontent.com/u/527 ... tion2.zipx

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: IsDBNull cannot give me the right result

Post by Pinturiccio » Wed 05 Jun 2013 13:53

We could not reproduce the issue. In our environment, the True value is displayed in both cases. Please provide the following information:
1. Oracle server version;
2. Oracle Client version;
3. The NLS parameters. To get these parameters, use the following query: "select * from nls_database_parameters".

xin_scott
Posts: 3
Joined: Wed 05 Jun 2013 02:40

Re: IsDBNull cannot give me the right result

Post by xin_scott » Thu 06 Jun 2013 02:03

the Devart.Data version is 5.0.392.0
the Devart.Data.Oracle version is 6.70.293.0
the Oracle Server version is 11.2.0.2.0
the Oracle Client version is 11.2.0.1.0
the NLS Parameters:
1 NLS_NCHAR_CHARACTERSET AL16UTF16
2 NLS_LANGUAGE AMERICAN
3 NLS_TERRITORY AMERICA
4 NLS_CURRENCY $
5 NLS_ISO_CURRENCY AMERICA
6 NLS_NUMERIC_CHARACTERS .,
7 NLS_CHARACTERSET WE8MSWIN1252
8 NLS_CALENDAR GREGORIAN
9 NLS_DATE_FORMAT DD-MON-RR
10 NLS_DATE_LANGUAGE AMERICAN
11 NLS_SORT BINARY
12 NLS_TIME_FORMAT HH.MI.SSXFF AM
13 NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
14 NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
15 NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
16 NLS_DUAL_CURRENCY $
17 NLS_COMP BINARY
18 NLS_LENGTH_SEMANTICS BYTE
19 NLS_NCHAR_CONV_EXCP FALSE
20 NLS_RDBMS_VERSION 11.2.0.2.0

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: IsDBNull cannot give me the right result

Post by Pinturiccio » Fri 07 Jun 2013 09:05

We have reproduced the issue. We will investigate it and notify you about the results as soon as possible.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: IsDBNull cannot give me the right result

Post by Pinturiccio » Wed 19 Jun 2013 12:58

We have fixed the bug with the IsDBNull method of the OracleDataReader method. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: IsDBNull cannot give me the right result

Post by Pinturiccio » Tue 25 Jun 2013 08:09

The new build of dotConnect for Oracle 7.7.267 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?t=27386

Post Reply