Problem with INSERT (...) RETURNING (...) and using DataReader
--------------------------------------------------------------

                 Key: DNET-770
                 URL: http://tracker.firebirdsql.org/browse/DNET-770
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 5.9.1.0
         Environment: Windows x64 ;  Firebird database 2.5.4 ;  
FirebirdSql.Data.FirebirdClient 5.9.1
            Reporter: Remigiusz Babicz
            Assignee: Jiri Cincura


INSERT (...) RETURNING (...) statement:
* works fine when using ExecuteScalar()
* doesn't work when using Executereader()


Full Code:

using System;
using FirebirdSql.Data.FirebirdClient;

namespace FirebirdClient
{
   class Program
   {
      static void Main(string[] args)
      {
         object generatedID;
         string command = @"
INSERT INTO CUSTOMER(CUSTOMER, CONTACT_FIRST, CONTACT_LAST, PHONE_NO, 
ADDRESS_LINE1, ADDRESS_LINE2, CITY, STATE_PROVINCE, COUNTRY, POSTAL_CODE, 
ON_HOLD)
VALUES('aaa', 'Jan','Kowalski', '1256', 'ulica', 'miasto', 'city', 'province', 
'USA', '123', '*' ) RETURNING CUST_NO";
         string connectionString = @"DataSource = localhost;Database = 
""localhost:C:\Program 
Files\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB""; User = sysdba; 
Password = masterkey";
         using (FbConnection con = new FbConnection(connectionString))
         {
            con.Open();
            using (FbCommand fbc = new FbCommand(command, con))
            {
               if (false)
               {
                  generatedID = fbc.ExecuteScalar(); //this works fine!
               }
               else
               {
                  //this doesn't work
                  FbDataReader dr = fbc.ExecuteReader();
                  int fielsCount = dr.FieldCount; //return 1
                  string namse = dr.GetName(0); //return CUST_NO
                  Type type = dr.GetFieldType(0); //return int
                  bool rows = dr.HasRows; //return false
                  bool read = dr.Read(); //return false
                  generatedID = dr.GetValue(0); //throws exception
               }
            }
         }
      }
   }
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to