Solved

Using Sessions

Posted on 1998-07-31
16
151 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

11 Experts available now in Live!

Get 1:1 Help Now