Link to home
Start Free TrialLog in
Avatar of quique
quique

asked on

Using Sessions

I would like someone to explain me quite detailed how to manage with sessions in Delphi 3.
My problem is I have an MDI application and want to create as many child-windows as users wants. Every child-window must have a session in order to be independant from the other child-windows. Resuming, every child-window is like a separate application.
Thanks.
Avatar of odessa
odessa

I don't understand very clear your question because the TSession in delphi only manage multiple access to DataBases (same or different), tell me more,
Zhasmin!
Hi guys. Zif, maybe he means threads? Threads do require a detailed explenation...
Hello,
var
  Form1: TForm1;
  myforms:array [0..65535] of Tcustomform;
  nd:word;

procedure TForm1.Button1Click(Sender: TObject);
begin
myforms[nd]:=Tcustomform.Createnew(self);
myforms[nd].Show;
inc(nd);
end;

Is it ?
PS: Sessions ? Database sessions you mean ?


Avatar of quique

ASKER

I need to explain a bit more my question.
My idea is to make an application that manages with a database in order to store and retrieve information to the user.
Until this point this is a simple database application.
But I have thought, it would be more useful and powerful if I could make MDI. But I have found a problem at this point.
I know how to make MDI applications and how to manage with child and parent windows, so this is all quite clear.
The problem appears when I try to do the following:
in my application the user can open as many child windows as he wants to. Every child windows will have TDBEdits connected to a TTable in order to show information from the database and will also have a TDBNavigator and some buttons to make some actions such as deleting, sorting, finding, etc. If we asume this, then the user can have 2 child windows opened at the same time with information of the same Table (for example, he has opened 2 windows, every one with information about a client in his business). If the user moves across one window, then data on the other window gets moved because they are connected to the same table in the same database. My problem is that I don't want this to happen. I want every window connected to a table independant from other windows that the user will open, even if they are connected to the same table. I have heard that TSessions can manage with this problem. If so, please tell me how to do it. Or if there is another way to do that, please tell it to mee too.
Looking forward to hearing from you, regards ....
You just need to add a set of TTables for each MDI windows and point them to the same table instead of using a common TTable.
Don't worry about TSessions right now, unless you want to work in threads, you can normally do without them..
Avatar of quique

ASKER

But, BlackMan, if I do what you tell me, would I have to repeat code? Would I have to do several kinds od MDI windows in order to show different data from different tables?
Is it the same windows that you show a number of times?
If you put the TTables on the MDI Child form, them there will be a instance for each windows and you don't have to repeat code..
Avatar of quique

ASKER

Ok, BlackMan, but you told me about a set of TTables for each MDI and then point them to the same table. Does this mean I have a Datamodule with 'real' tables and then I point the instances of the MDI windows to these 'real' tables? How can I do this? Is it something like this?:

I have a Datamodule called DM1 with a table called Table1.

I have a MDI window with a table called TableMDI.

Shall I put on the OnCreate event of the MDI window:

Tform1.Oncreate ...
begin
    TableMDI := DM1.Table1;
end;

Is this right? If so, I have tried it and it doesn't work (obviously I have Attached a datasource to the TableMDI in order to show data on TDBEdits).
Things get a bit more complicated if you have a DataModule with some logic in.. There is a unit called CloneTable, which you might want to try. This enable you to make a clone of the table in the DataModule each time you create a MDI child. Check http://www.bhnet.com.br/~demian/
What I meant in my previous comment, was that you could put a TTable on your MDI form and then set the properties on that one instead of using a DataModule.
Avatar of quique

ASKER

C
Maybe you can just add some variable to each MDIChild window with the value of TTable.RecNo. So when the user changes something, just move to the right record.

Can't you use a simple TEdit instead of TDBEdit?

Or mybe TQuery?
It's me again...

quique, did you really need DataModule? If not, you can do so:
If you have a MDIChild with TableMDI, then in OnCreate event of MDIChild write

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TableMDI do begin
    TableName:='C:\Test.db';
    TableType:=ttParadox;
    Exclusive:=false;
    ...
    {Some other values like IndexNames, Filter, etc.}
    ...
    Open; {you have a table}
  end;  
end;


quique, are you still there??
Avatar of quique

ASKER

Blackman, I need an answer in order to give you the points, not a comment!
ASKER CERTIFIED SOLUTION
Avatar of BlackMan
BlackMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I wasn't sure if you were satisfied :-)