Key field problems when re-using UniTable

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tw
Posts: 2
Joined: Thu 12 Aug 2010 16:38

Key field problems when re-using UniTable

Post by tw » Thu 12 Aug 2010 17:15

Hi,

I'm working with Delphi 2005 and UniDAC 3.0.0.10, I'm accessing an Oracle database.

An UniTable component is used to append new data to several different existing tables. This is working properly for the first table after start of the application - regardless, which one.
But if I close the table, assign a different TableName and try to write to that second table, I will always get an error like "Key field 'KEY1' not found'. This field is a key field of the first table, but does not exist in the second one. Looks like the UniTable is caching the key field information somewhere?

Code is basically

Code: Select all

     UniTable1.TableName:= 'TEST.FIRSTTABLE';
     UniTable1.Active:= true;
     UniTable1.Append;
     UniTable1 ['KEYFIELD1']:= 'Test';
     UniTable1 ['NORMALFIELD2']:= 'Test';
     UniTable1.Post;   // works fine
     UniTable1.Active:= false;

     UniTable1.TableName:= 'TEST.NEXTTABLE';
     UniTable1.Active:= true;
     UniTable1.Append;
     UniTable1 ['DIFFERENTKEYFIELD1']:= 'Test';
     UniTable1 ['ANOTHERFIELD2']:= 'Test';
     UniTable1.Post; 
-> Errormessage "Key field 'KEYFIELD1' not found"

What can I do?

Thanks
tw

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 13 Aug 2010 11:26

Hello,


Thank you for the information.
We will try to resolve this issue.
Now to resolve this issue you can set UniTable1.KeyFields := '' after closing a table.

tw
Posts: 2
Joined: Thu 12 Aug 2010 16:38

Post by tw » Fri 13 Aug 2010 13:32

Thanks for the quick reply, your workaround does work!

halenpolen
Posts: 31
Joined: Sun 27 Jun 2010 20:50

same problem

Post by halenpolen » Sun 05 Sep 2010 02:24

Hi I have same problem;
I'm working with msqlsserver 2008,
delphi 7 with code:

Code: Select all

uniconnection1.options.disconnectedmode:=true;
uniconnection1.Connected:=true;
unitable1.Keyfields:='Key1';
unitable1.open;
when I KILL client connection from the server(using kill [session ID])
then i refresh the unitable1 sometimes it couldn't open
with message error:

EDatabaseError with message 'unitable1: Key field 'Key1' not found'

if I set: unitable1.Keyfields:=''; there is error with message:

Exception class EFailOver with message ''

Thanks
Last edited by halenpolen on Mon 06 Sep 2010 10:01, edited 2 times in total.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 06 Sep 2010 08:31

Hello,


If you set the DisconnectedMode option to True you don't need to open a connection manually.
In disconnected mode a connection is opened for executing requests to the server (if it was not opened already) and is closed automatically if it is not required any more.
If the connection was explicitly opened (the Connect method was called or the Connected property was explicitly set to True), it does not close until the Disonnect method is called or the Connected property is set to False explicitly.

See the Working with Disconnected Mode topic in the UniDAC help for more information.

halenpolen
Posts: 31
Joined: Sun 27 Jun 2010 20:50

Post by halenpolen » Mon 06 Sep 2010 09:25

AlexP wrote: See the Working with Disconnected Mode topic in the UniDAC help for more information.
Thx Alex, I red that help before, I used uniconnection1.Connected:=true; or not used it, I still got same strange errors
,to handle that error I must to close unitable1 then open.

I can'nt directly using unitable1.refresh or unitable1.execute

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 06 Sep 2010 11:52

Hello,

I could not reproduce the problem.
Please send me a complete small sample to alexp*devart*com to demonstrate it.

halenpolen
Posts: 31
Joined: Sun 27 Jun 2010 20:50

Post by halenpolen » Mon 06 Sep 2010 19:16

AlexP wrote:Hello,

I could not reproduce the problem.
Please send me a complete small sample to alexp*devart*com to demonstrate it.
I'm using this sample:
\Demos\Win32\Miscellaneous\FailOver (Delphi 2007,unidac 3.00.0.11)
I remove this discussion cause same:
http://www.devart.com/forums/viewtopic. ... 0614#60614

Post Reply