• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

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.
0
quique
Asked:
quique
  • 6
  • 5
  • 2
  • +3
1 Solution
 
odessaCommented:
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!
0
 
MatveyCommented:
Hi guys. Zif, maybe he means threads? Threads do require a detailed explenation...
0
 
jecksomCommented:
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 ?


0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
quiqueAuthor Commented:
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 ....
0
 
BlackManCommented:
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..
0
 
quiqueAuthor Commented:
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?
0
 
BlackManCommented:
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..
0
 
quiqueAuthor Commented:
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).
0
 
BlackManCommented:
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.
0
 
quiqueAuthor Commented:
C
0
 
333Commented:
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?
0
 
333Commented:
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;


0
 
BlackManCommented:
quique, are you still there??
0
 
quiqueAuthor Commented:
Blackman, I need an answer in order to give you the points, not a comment!
0
 
BlackManCommented:
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.
0
 
BlackManCommented:
I wasn't sure if you were satisfied :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 5
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now