Page 1 of 1

Key field problems when re-using UniTable

Posted: Thu 12 Aug 2010 17:15
by tw
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

Posted: Fri 13 Aug 2010 11:26
by AlexP
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.

Posted: Fri 13 Aug 2010 13:32
by tw
Thanks for the quick reply, your workaround does work!

same problem

Posted: Sun 05 Sep 2010 02:24
by halenpolen
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

Posted: Mon 06 Sep 2010 08:31
by AlexP
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.

Posted: Mon 06 Sep 2010 09:25
by halenpolen
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

Posted: Mon 06 Sep 2010 11:52
by AlexP
Hello,

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

Posted: Mon 06 Sep 2010 19:16
by halenpolen
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