New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with INSERT (...) RETURNING (...) and using DataReader [DNET770] #710
Comments
Commented by: Andre Litfin (andrelitfin) You can change Method Fetch() in GdsStatement.cs and FesStatement and write
instead of
to make it work :-) |
Commented by: Rafael Almeida (ralmsdeveloper) Very good suggestion Andre Litfin , these days I had this need. I'll be trying to help Cincura. I did some testing here and everything went well! |
Modified by: @cincuranet |
Modified by: @cincuranet |
Modified by: @cincuranet |
Modified by: @cincuranetstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 6.0.0.0 [ 10850 ] |
Modified by: @cincuranetsummary: Problem with INSERT (...) RETURNING (...) and using DataReader => Problem with INSERT (...) RETURNING (...) and using DataReader #breaking |
Submitted by: Remigiusz Babicz (reik)
Is duplicated by DNET319
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
}
}
}
}
}
}
Commits: d3f9cd2
The text was updated successfully, but these errors were encountered: