Page 1 of 1
DisconnectedMode
Posted: Tue 21 Apr 2009 18:57
by MarkF
Is there any other way to have a dataset retain its data after logout besides using DisconnectedMode set to true? Basically I don't want to turn disconnectedmode on in my application because it causes some state issues for me, but I'd like to be able to have my datasets keep their data.
Thanks for any help.
-Mark Ford
Benthic Software
In addition:
The documentation suggests that if Connect is explicitly called, then the connection will not be closed automatically (when using disconnectedmode set to true) however it appears that that is not the case (or I'm using it or understanding the use incorrectly.) If the connection didn't close in this case than it would solve my issues above. Any comments?
Posted: Wed 22 Apr 2009 06:57
by Plash
No, ODAC supports this feature only in the disconnected mode.
If Connect is explicitly called, the connection should not be closed. Please describe how to reproduce the problem when the connection closes.
Posted: Wed 22 Apr 2009 10:43
by MarkF
It looks like FConnectCount can fall to zero even if connect is explicitly called. I think it has something to do with autocommit set to false, and then calling session.commit in my code. It looks like it takes a few tries (in my program) before it decrements the counter enough to disconnect.
I wonder if it would be better to use a different boolean variable to designate that the user has explicitly called connect? It seems like FConnectCount could be accidentally decremented pretty easily. I see it gets set and reset quite a bit and is a bit hard to debug.
I'll try to make a simple example that causes the problem.
Thanks for the help.
-Mark
Posted: Wed 22 Apr 2009 20:00
by MarkF
My guess above was correct. Calling either commit or rollback will cause the bug if Autocommit is false. Note that there's a comment in the code with a special check for FConnectCount < 0 that seems to be related to this.
Code: Select all
var
OraSession: TOraSession;
OraQuery: TOraQuery;
begin
OraSession := TOraSession.Create(nil);
OraSession.ConnectPrompt := False;
OraSession.AutoCommit := False;
OraSession.ThreadSafety := True;
OraSession.Options.DisconnectedMode := True;
OraQuery := TOraQuery.Create(nil);
OraQuery.Session := OraSession;
OraQuery.ReadOnly := True;
OraQuery.AutoCommit := False;
OraSession.Username := 'scott';
OraSession.Password := 'tiger';
OraSession.Server := 'mfms3';
OraSession.Connect;
OraQuery.SQL.Text := 'select * from emp';
OraQuery.Execute;
while not OraQuery.eof do
OraQuery.Next;
OraSession.Commit;
if not OraSession.Connected then
ShowMessage('Session disconnected due to FConnectCount issue.');
OraQuery.Free;
OraSession.Free;
end;
Let me know if you have any questions or comments!
-Mark
Posted: Mon 27 Apr 2009 11:22
by Plash
We have fixed this problem. The fix will be included in the next build of ODAC.
Posted: Tue 28 Apr 2009 02:12
by MarkF
Thanks!
-Mark
Posted: Tue 26 May 2009 17:56
by Ludek
I have similar issue with SDAC. in disconnected mode the connection is closed, althouh I have the connect method explicitly called. affects the odac correction also the sdac bug? when it will be available?
Posted: Wed 27 May 2009 07:12
by Plash
This correction does not affect SDAC. Please describe the steps to reproduce the problem.
Posted: Wed 27 May 2009 09:19
by Ludek
following steps: create a tmsconnection with disconnectedmode := true, call connect to make the connection active.
then execute following code:
Code: Select all
msq := TMSQuery.Create(nil);
try
msq.Connection := msconnection1;
msq.SQL.Text := 'select value from useroptions where usernr = :usernr and optionnr = :optionnr';
msq.ParamByName('usernr').DataType := ftInteger;
msq.ParamByName('usernr').Clear;
msq.ParamByName('optionnr').AsInteger := 97;
// msq.CommandTimeout := 0;
msq.Open;
msq.Close;
finally
msq.Free;
end;
and the connection disconnects (you can see an audit logout in the profiler)
the useroptions is a simple table with the 3 named columns, all integer.
the logout happens only if the one parameter is NULL. if i include a value
Code: Select all
msq := TMSQuery.Create(nil);
try
msq.Connection := msconnection1;
msq.SQL.Text := 'select value from useroptions where usernr = :usernr and optionnr = :optionnr';
msq.ParamByName('usernr').DataType := ftInteger;
msq.ParamByName('usernr').AsInteger := 1;
msq.ParamByName('optionnr').AsInteger := 97;
// msq.CommandTimeout := 0;
msq.Open;
msq.Close;
finally
msq.Free;
end;
the connection remains open...

Posted: Wed 27 May 2009 09:27
by Ludek
more info: the connection closes (audit logout in profiler), if the query returns 0 rows.
Posted: Wed 27 May 2009 11:27
by Dimon
Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SDAC build.
Posted: Wed 27 May 2009 12:19
by Ludek
Thanks much. I just can't wait for the new build
