DisconnectedMode
DisconnectedMode
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?
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?
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
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
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.
Let me know if you have any questions or comments!
-Mark
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;
-Mark
following steps: create a tmsconnection with disconnectedmode := true, call connect to make the connection active.
then execute following code:
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
the connection remains open...

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;
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...