Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-514

[ADO.NET] CUBRIDCommand.ExecuteReader(CommandBehavior behavior) does not work

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: ADONET-Aprium, ADONET-9.1.0
    • Fix Version/s: ADO.NET 9.2.0.0001
    • Component/s: ADO.NET
    • Labels:

      Description

      Description:
      CUBRIDCommand.ExecuteDbDataReader(CommandBehavior behavior) does not work.

      Repro Steps:
      Scenario 1

       
      conn.ConnectionString = DBHelper.connString;
                      conn.Open();
      
                      string sql = "select * from nation order by code asc";
                      CUBRIDCommand cmd = new CUBRIDCommand(sql, conn);
      CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader(CommandBehavior.CloseConnection);
      reader.Close();
      

      at this point, check the following points:
      reader.IsClosed
      conn.connState

      Expected Results:
      reader.IsClosed is true;
      conn.connState is ConnectionState.Closed

      Actual Results:
      reader.IsClosed is true;
      conn.connState is ConnectionState.Open

      Scenario 2

       
      conn.ConnectionString = DBHelper.connString;
                      conn.Open();
      
                      string sql = "select * from nation order by code asc";
                      CUBRIDCommand cmd = new CUBRIDCommand(sql, conn);
      reader = (CUBRIDDataReader)cmd.ExecuteReader(CommandBehavior.SingleRow);
      
                      //verify the first two results
                      reader.Read();
                      Assert.AreEqual(4, reader.FieldCount);
                      Assert.AreEqual("AFG", reader.GetString(0));
                      Assert.AreEqual("Afghanistan", reader.GetString(1));
                      Assert.AreEqual("Asia", reader.GetString(2));
                      Assert.AreEqual("Kabul", reader.GetString(3));
      
                      try
                      {
                          bool result = reader.Read();
                          Assert.AreEqual(4, reader.FieldCount);
                          Assert.AreEqual("AHO", reader.GetString(0));
                          Assert.AreEqual("Netherlands Antilles", reader.GetString(1));
                          Assert.AreEqual("Americas", reader.GetString(2));
                          Assert.AreEqual("Willemstad", reader.GetString(3));
                      }
                      catch (Exception ex)
                      {
                          Log(ex.Message);
                      }
      

       
      Expected Results:
      reader can only ready one row

      Actual Results:
      reader.Read() returns true;
      The second row can be read.

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment -

        ADO.net driver don't implement the interface:ExecuteReader(CommandBehavior)

        Show
        cn15800 谢韦华[Bert] added a comment - ADO.net driver don't implement the interface:ExecuteReader(CommandBehavior)
        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        After modify:

        {code}
        reader = (CUBRIDDataReader)cmd.ExecuteReader(CommandBehavior.SingleRow);

        //verify the first two results
        reader.Read();
        Assert.AreEqual(4, reader.FieldCount);
        Assert.AreEqual("AFG", reader.GetString(0));
        try
        { bool result = reader.Read(); //result is false Assert.AreEqual(4, reader.FieldCount); Assert.AreEqual("AHO", reader.GetString(0)); //reader.GetString(0) is AFG. }
        catch (Exception ex)
        { Log(ex.Message); }
        {code}
        Show
        cn15800 谢韦华[Bert] added a comment - - edited After modify: {code} reader = (CUBRIDDataReader)cmd.ExecuteReader(CommandBehavior.SingleRow); //verify the first two results reader.Read(); Assert.AreEqual(4, reader.FieldCount); Assert.AreEqual("AFG", reader.GetString(0)); try { bool result = reader.Read(); //result is false Assert.AreEqual(4, reader.FieldCount); Assert.AreEqual("AHO", reader.GetString(0)); //reader.GetString(0) is AFG. } catch (Exception ex) { Log(ex.Message); } {code}
        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        The program will not throw exception, when the number of row is bigger than 2.

        reader.Read() will return false.

        Show
        cn15800 谢韦华[Bert] added a comment - - edited The program will not throw exception, when the number of row is bigger than 2. reader.Read() will return false.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        It is same with oledb driver.

        Show
        cn15800 谢韦华[Bert] added a comment - It is same with oledb driver.
        Hide
        cn15800 谢韦华[Bert] added a comment -

        fixed

        Show
        cn15800 谢韦华[Bert] added a comment - fixed
        Hide
        ryin005 Ray Yin added a comment -
        • Test OS: Win32 bit
        • CUBRID: 9.2.0.0149
        • Driver: cubrid-ado.net 9.2.0.0002 (20130911)
        • Framework: .NET 4.0

        Test Result: Pass

        Show
        ryin005 Ray Yin added a comment - Test OS: Win32 bit CUBRID: 9.2.0.0149 Driver: cubrid-ado.net 9.2.0.0002 (20130911) Framework: .NET 4.0 Test Result: Pass

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            cn15701 cuiman
            CC (Referrer):
            cuiman, Kai Yang (Inactive), 李应
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: