How to change uniquery1.connection property
-
- Posts: 31
- Joined: Sun 27 Jun 2010 20:50
How to change uniquery1.connection property
Hi
How to change uniquery1.connection property with another uniconnection without making close uniquery ???
I have tried it but uniquery always automatically closed
procedure TForm1.Button8Click(Sender: TObject);
begin
UniQuery1.Connection:=UniConnection1;
UniConnection1.Options.DisconnectedMode:=true;
UniQuery1.Connection:=UniConnection2; //<-- this is the problem uniquery1 automatically closed
end;
if I using Tadoconnection , adoquery1 doesn't close
procedure TForm1.Button9Click(Sender: TObject);
begin
ADOQuery1.Connection:=ADOConnection1;
ADOConnection1.Open;
ADOQuery1.Open;
ADOQuery1.Connection:=nil;
ADOConnection1.Close;
ADOConnection2.Open;
ADOQuery1.Connection:=ADOConnection2;//<- adoquery1 doesn't close
end;
--------------------------------
How to reconnect uniconnection if there is fail connection??
I already used : UniConnection1.Options.DisconnectedMode:=true;, but uniquery still have to close . I want to reconnect without change current cursor uniquery.
thanks
How to change uniquery1.connection property with another uniconnection without making close uniquery ???
I have tried it but uniquery always automatically closed
procedure TForm1.Button8Click(Sender: TObject);
begin
UniQuery1.Connection:=UniConnection1;
UniConnection1.Options.DisconnectedMode:=true;
UniQuery1.Connection:=UniConnection2; //<-- this is the problem uniquery1 automatically closed
end;
if I using Tadoconnection , adoquery1 doesn't close
procedure TForm1.Button9Click(Sender: TObject);
begin
ADOQuery1.Connection:=ADOConnection1;
ADOConnection1.Open;
ADOQuery1.Open;
ADOQuery1.Connection:=nil;
ADOConnection1.Close;
ADOConnection2.Open;
ADOQuery1.Connection:=ADOConnection2;//<- adoquery1 doesn't close
end;
--------------------------------
How to reconnect uniconnection if there is fail connection??
I already used : UniConnection1.Options.DisconnectedMode:=true;, but uniquery still have to close . I want to reconnect without change current cursor uniquery.
thanks
Hello,
You can not change the TUniQury.Connection property without closing TUniQuery.
Even if you set the TADOQuery.Connection to nil or even if you set the TADOQuery.Connection again, TADOQuery won't lose the set connection until you close TADOQuery.
Now we can not implement such behaviour, we will consider adding this possibility in the future versions of UniDAC.
You can not change the TUniQury.Connection property without closing TUniQuery.
Even if you set the TADOQuery.Connection to nil or even if you set the TADOQuery.Connection again, TADOQuery won't lose the set connection until you close TADOQuery.
Now we can not implement such behaviour, we will consider adding this possibility in the future versions of UniDAC.
-
- Posts: 31
- Joined: Sun 27 Jun 2010 20:50
Thanks Alex, I will wait that version.AlexP wrote: we will consider adding this possibility in the future versions of UniDAC.
I using unidac 3.00.0.11
I tried this demo :
\Demos\Win32\Miscellaneous\FailOver
, but this demo cann't handle kill session errors very well (default setting).
when quMaster and qudetail was opened,
If I click button kill session, then edit dname(master table) than applyupdates,then refresh , I got error List index out bound(0), then I click open or close button, but it cann't open with error communcation link failure. I have to terminate the demo program, and start again to click open.
when quMaster and qudetail was opened,
If I click button kill session, then edit ename(DETAIL table) than applyupdates,(error violation at address 00403283)then refresh , I got error List index out bound(0), then I change cursor master to another deptno, I got error Field Depno not found. then I click open or close button, but it cann't open with error communcation link failure. I have to terminate the demo program, and start again to click open.
The conclusion
I got 4 strange errors, after those finallly, I have to terminate the program cause dataset can't open.
the errors are:
1. List index out bound(0)
2.error violation at address 00403283
3.Field Depno not found
4. communcation link failure
Must I change the default setting demo program so it can handle fail connection very well?? I'm searching the way to reconnect without change current cursor uniquery and without close or open uniquery. (I used Tadoconnection/tadoquery before and it can handle very well)
Hello,
If you connect to database before opening datasets then using disconnected mode has no advantages. You should use the Open method only. In this case you connect to database only when it's necessary (fetch data, apply updates, etc.).
Also you don't need to use the Failover and Pooling options.
Set the following options in the Failover demo project like this:
CachedUpdates = true
LocalMasterDetail = true
FetchAll = true
DisconnectedMode = true
Failover = false
Pooling = false
and try again
If you connect to database before opening datasets then using disconnected mode has no advantages. You should use the Open method only. In this case you connect to database only when it's necessary (fetch data, apply updates, etc.).
Also you don't need to use the Failover and Pooling options.
Set the following options in the Failover demo project like this:
CachedUpdates = true
LocalMasterDetail = true
FetchAll = true
DisconnectedMode = true
Failover = false
Pooling = false
and try again
-
- Posts: 31
- Joined: Sun 27 Jun 2010 20:50
Hi I still got same errors.AlexP wrote:Hello,
Set the following options in the Failover demo project like this:
CachedUpdates = true
LocalMasterDetail = true
FetchAll = true
DisconnectedMode = true
Failover = false
Pooling = false
when I click kill session then REFRESH master/detail the DBGrid became empty row, I must click twice Refresh then DBGrid back normally(with cursor data on the first rows)
I must get bookmark dataset on event before disconnect, on event after connect I must set bookmark dataset(worst way to back cursor dataset) . With Tadoquery it doesn'not happend.
Sometimes I got message 'List index out bound(0)' repeatedly. then I must terminate program
If the Detail dataset is empty, Click kill session then I refresh Master dataset. I got message 'Field Depno not found', I must close and open dataset because the message always appeared;
hello,
If you want to use Disconnect Mode you don't need to connect to database, in this mode a connection opens only when it is required.
Run the FailOver demo project, click the Open button (not Connect),
execute the following query
use master
go
select * from sysprocesses (nolock) where program_name= 'FailOver.exe'
go
as you can see your session is missing.
After performing all server calls connection closes automatically until next server call is required. Datasets remain opened when connection closes.
If you want to use Disconnect Mode you don't need to connect to database, in this mode a connection opens only when it is required.
Run the FailOver demo project, click the Open button (not Connect),
execute the following query
use master
go
select * from sysprocesses (nolock) where program_name= 'FailOver.exe'
go
as you can see your session is missing.
After performing all server calls connection closes automatically until next server call is required. Datasets remain opened when connection closes.
-
- Posts: 31
- Joined: Sun 27 Jun 2010 20:50
Thanks AlexP for Ur explanationAlexP wrote: If you want to use Disconnect Mode you don't need to connect to database, in this mode a connection opens only when it is required.
Run the FailOver demo project, click the Open button (not Connect),
execute the following query

Now I got the new problem
I set options in the Failover demo project like this:
CachedUpdates =false
LocalMasterDetail = false
FetchAll = true
DisconnectedMode = false
Failover = true
Pooling = false
I click kill session, the program can reconnect or reconnectexecute very well without closing qumaster/qudetail.
but if I start transaction->click kill session->edit something and post/commit it,->message error->suddenly, qumaster/qudetail close automatically. Can qumaster/qudetail still open ??? How?? (with same options) Can it run like event connectionlost to reconnectrollback/only reconnect
-
- Posts: 31
- Joined: Sun 27 Jun 2010 20:50
I have got the problem
I set options in the Failover demo project like this:
CachedUpdates =false
LocalMasterDetail = false
FetchAll = true
DisconnectedMode = false
Failover = true
Pooling = false
I clicked kill session, the program can reconnect or reconnectexecute very well without closing qumaster/qudetail.
But if I Start Transaction->clicked kill session->edit something data then Post/Commit it,->message error appears(TCP Provide : An existing connection was forcibly closed by the remote host)->SUDDENLY, qumaster/qudetail close automatically. Can qumaster/qudetail still open ??? How?? (with same options) Can it run like event connectionlost to reconnectrollback or only reconnect???
I set options in the Failover demo project like this:
CachedUpdates =false
LocalMasterDetail = false
FetchAll = true
DisconnectedMode = false
Failover = true
Pooling = false
I clicked kill session, the program can reconnect or reconnectexecute very well without closing qumaster/qudetail.
But if I Start Transaction->clicked kill session->edit something data then Post/Commit it,->message error appears(TCP Provide : An existing connection was forcibly closed by the remote host)->SUDDENLY, qumaster/qudetail close automatically. Can qumaster/qudetail still open ??? How?? (with same options) Can it run like event connectionlost to reconnectrollback or only reconnect???
Hello,
After killing connection, disconnecting cable, or any other reasons that result in connection loss, all open datasets will be closed, but if you want to keep open datasets you should use the DisconnectedMode property (DisconnectedMode=true) and should not use preconnection in this case.
After connection loss all started transactions will automaticaly rollback and will be closed on the server, and you won't be able to work with them.
After killing connection, disconnecting cable, or any other reasons that result in connection loss, all open datasets will be closed, but if you want to keep open datasets you should use the DisconnectedMode property (DisconnectedMode=true) and should not use preconnection in this case.
After connection loss all started transactions will automaticaly rollback and will be closed on the server, and you won't be able to work with them.