Skip to content
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

FbCommandBuilder has problems with Calculated fields [DNET100] #112

Closed
firebird-automations opened this issue Jun 27, 2007 · 22 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Eduardo Gamboa (bestrafender)

When I try to insert new rows using FbDataAdapter and FbCommandBuilder an exception is thrown when the table has calculated fields.(e.g)
/****************************************/
CREATE TABLE CONTACTS (
FIRST_NAME VARCHAR(32) NOT NULL,
LAST_NAME VARCHAR(32),
FULL_NAME COMPUTED BY (FIRST_NAME ||' '|| LAST_NAME)
);

/****************************************/
using System;
using System.Collections.Generic;
using System.Text;
using FirebirdSql.Data.FirebirdClient;
using System.Data;

namespace FBCommanBuilderTest
{
class Program
{
static void Main(string[] args)
{
try
{
FbConnectionStringBuilder fbCsb = new FbConnectionStringBuilder();
fbCsb.Dialect = 3;
fbCsb.UserID = "SYSDBA";
fbCsb.Password = "masterkey";
fbCsb.Database = @"localhost:d:\my projects\firebird databases\test.fdb";
FbConnection fbConn = new FbConnection(fbCsb.ConnectionString);
fbConn.Open();
string strCmd = "SELECT * FROM \"CONTACTS\"";
FbDataAdapter fbDA = new FbDataAdapter(strCmd, fbConn);
FbCommandBuilder fbCB = new FbCommandBuilder(fbDA);
DataSet ds = new DataSet();
fbDA.Fill(ds, "Contacts");
object[] values = new object[3];
values[0] = "EDUARDO";
values[1] = "GAMBOA";
values[2] = "DUMMY VALUE";
ds.Tables["Contacts"].Rows.Add(values);
fbDA.Update(ds.Tables["Contacts"]);
fbConn.Close();
Console.WriteLine("Ok.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error:");
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
}

Commits: 2a981a5 cef6739

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Carlos, this column should be set as read-only, for this case: ds.Tables["Contacts"].Columns[2].ReadOnly = true;

I'm trying to find some fix.

@firebird-automations
Copy link
Author

Commented by: @carlosga

Sure, i will try to review the FbDataReader.GetSchemaTable implementation as soon as possible

@firebird-automations
Copy link
Author

Modified by: @carlosga

Fix Version: 2.1.0 RC 2 [ 10180 ]

priority: Blocker [ 1 ]

@firebird-automations
Copy link
Author

Commented by: @cincuranet

SchemaTable is OK. The 3rd column is marked as read-only.

@firebird-automations
Copy link
Author

Commented by: @carlosga

So the DbCommanBuilder class so triying to generate parameters for all columns without checking if they are readonly or not ?? huummmm

@firebird-automations
Copy link
Author

Commented by: @carlosga

What is the value of the IsExpression column returned by the GetSchemaTable ??

@firebird-automations
Copy link
Author

Commented by: @cincuranet

It's false. Maybe the problem.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

OK, we've got a problem. The IsExpression method from DbField.cs is not saying true. It's getting result, whether is expression or not from length of Name property. This isn't good, because every column in FB has some name.

We should look into RDB$COMPUTED_SOURCE. I'll try to find the solution ASAP.

@firebird-automations
Copy link
Author

Commented by: @carlosga

But it comes as empty for fields that aren't part of the table, if i remember well ( while i agree the way it's done isn't the best ;) )

So we can modify the select used to get the information in GetSchemaTable to fetch the RDB$COMPUTED_SOURCE and check it this friday ( haven't .net installed right now )

@firebird-automations
Copy link
Author

Commented by: @cincuranet

I'll send you e-mail with aditional info to not spam tracker.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

assignee: Carlos Guzman Alvarez [ carlosga_fb ] => Jiri Cincura [ cincura_net ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Commented by: Eduardo Gamboa (bestrafender)

Hi Guys,

I just want to know if this change has been submitted to SVN?
I just built the assembly from the revision 306 and I am still having the same error:
**** attempted update of read-only column ****

Thanks in advance
Eduardo Gamboa

@firebird-automations
Copy link
Author

Commented by: @cincuranet

306 should be OK.

When I run your code, it's ok, no exception. Did you rebuild you application to use new version of provider? And are you referencing right file?

@firebird-automations
Copy link
Author

Commented by: Eduardo Gamboa (bestrafender)

Yes, I re-built my app, and I am sure I am referencing the new assembly because a can verify the change for DNET90 I reported earlier.
I am using the employee.fbd sample database for the test and I am updating a row in the SALES table. Here is were I get the error.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Send to my email (mailto:jiri@cincura.net) sample app. I'll review this.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

I have tested your case here you put. Just Cut'n'Paste and fresh build of provider and it works. You're probably referencing wrong assembly.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

I got the testapp.

You're not referencing new assembly. You have <Reference Include="FirebirdSql.Data.FirebirdClient, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL" />
but the current trunk has 2.5.0.0 version number.

@firebird-automations
Copy link
Author

Commented by: Eduardo Gamboa (bestrafender)

Sorry,

My bad, I was using the NetProvider_210 branch instead of the trunk.

Now the calculate-field problem is fixed, but a new problem surfaced.
The following code worked fine before:

DataSet ds = new DataSet();
ds.Tables.Add(fbConn.GetSchema("Tables"));

but now it throws the exception:

Object reference not set to an instance of an object.

Should I open a new bug report for this?

@firebird-automations
Copy link
Author

Commented by: @cincuranet

'Cause you don't provide test case, it's hard to decide whether and where is the problem.

Create new ticket and there post testcase. I'll look at it.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants