Solved

Using Sessions

Posted on 1998-07-31
16
154 Views
Last Modified: 2010-04-04
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
Comment
Question by:quique
  • 6
  • 5
  • 2
  • +3
16 Comments
 
LVL 2

Expert Comment

by:odessa
ID: 1359352
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
 
LVL 3

Expert Comment

by:Matvey
ID: 1359353
Hi guys. Zif, maybe he means threads? Threads do require a detailed explenation...
0
 
LVL 1

Expert Comment

by:jecksom
ID: 1359354
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
 
LVL 1

Author Comment

by:quique
ID: 1359355
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
 
LVL 7

Expert Comment

by:BlackMan
ID: 1359356
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
 
LVL 1

Author Comment

by:quique
ID: 1359357
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
 
LVL 7

Expert Comment

by:BlackMan
ID: 1359358
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
 
LVL 1

Author Comment

by:quique
ID: 1359359
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Expert Comment

by:BlackMan
ID: 1359360
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
 
LVL 1

Author Comment

by:quique
ID: 1359361
C
0
 
LVL 2

Expert Comment

by:333
ID: 1359362
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
 
LVL 2

Expert Comment

by:333
ID: 1359363
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
 
LVL 7

Expert Comment

by:BlackMan
ID: 1359364
quique, are you still there??
0
 
LVL 1

Author Comment

by:quique
ID: 1359365
Blackman, I need an answer in order to give you the points, not a comment!
0
 
LVL 7

Accepted Solution

by:
BlackMan earned 200 total points
ID: 1359366
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
 
LVL 7

Expert Comment

by:BlackMan
ID: 1359367
I wasn't sure if you were satisfied :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now