Solved

MDI Forms and Paradox over Network

Posted on 2001-07-05
19
269 Views
Last Modified: 2010-04-06
I need to build an app that can work with 2 on a network, using 2 MDIChildForms accessing 2 different TTables.
The user needs to edit or insert records in both MDIChildForms at the same time.

The Problem is:
If I add only 1 TDatabase to my datamodule, and link my TTables to it, the user can only start one Transaction at one form, when he tries to insert/edit a record on the other window a message comes up, "A user transaction is already in progress".

Using TDatabase is the best way to make a MDI Paradox based program work on a windows network?
Do I need to add 1 TDatabase for each TTable component on my datamodule?
If so, can I do it at runtime?

Samples are welcome!

Thanks,
 
VSF
hereim@ig.com.br
www.victory.hpg.com.br
www.enge.cjb.net

0
Comment
Question by:VSF
  • 8
  • 6
  • 3
  • +1
19 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6257010
Use a TSession object...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6257053
firsttime->listening ... not time yet
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6257104
VSF, do you have the TTable active while in design mode? If so, this may be the cause of the trouble. First compile the project, quit Delphi and try to run the exe. It should work then... (I hope).

The TSession is not necessary but it could be wise to use it.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6258436
hi again,

guessing you are using two ttable instances,
and so, if one instance is in edit mode (or in transaction), the other instance can't do this for the same record.

if so, then i would use a tdatamodule, where is placed one tableinstance, and the mdi-forms are connecting to it with a datasource instance each.

if not so,
then just ask the tdatabase, if it is intransaction,
if not then starttransaction, if yes then do not starttransaction, because a transaction is already established.

if you will use different transactions then you may use more tdatabases.

meikl ;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6258653
The problem is that Delphi (5) does not release everything when you close the database connection (TDatabase.Active property) in designtime (bug in BDE?). At least that is what I experienced. I had to close Delphi before I could properly access the database again.
To avoid this problem while testing in Delphi, keep TDatabase.Active false. In the TMDICild.OnCreate event set Database1.Active to true, so it will only connect at runtime.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6258721
hehe, eps, catched you :-))
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6258730
Hardly anyone responds the last 2 days...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6258747
yup, thats true, happens to me too :-(
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6258955
Hi VSF,
meikl :-)
epsilon :-)

There is two different tables. Seems transaction started on insert or on edit event.  The way is to start transaction just before post event and commit it after post. So, it will take very short period of time.

May be I miss somethig :-)

-----
Igor
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6259072
hi igor :-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6259118
hi all :o)
0
 
LVL 3

Author Comment

by:VSF
ID: 6259360
Ok.
So I should add one TDatabase for each table in my datamodule, is that right?!
(I think Tdatabase can only support one transaction to be opened at a time.)

Adding one Tdatabase for each table will damage too much memory? Hope not!

Epsylon:
My Tdatabase is active false, just like my Ttables in desing time.
I use Tdatabase.connected:=true; on my OnCreate Event.

0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 6259543
i would guess yes.

if you've many tables,
then may also a tdatabase runtime-creation
on demand possible.

meikl ;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6259570
Why not putting the TDatabase and TTable on the MDIChild window? This also means that the DataModule will be empty. And I think you need a TSession on the MDIChild window.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6259606
yould be also a choice, eps,
tsession i guess is not needed,
if no one exists the default session is taken

meikl ;-)
0
 
LVL 3

Author Comment

by:VSF
ID: 6260053
One table can be accessed from more than one form for reading and accessed by a single form for writing!
The form are not AutoCreate

That's why I'd rather put the Ttables on a datamodule.

The big problem will be add a Tdatabase for each Ttable.

I'm seriously thinking of migrating to Interbase ASAP.

VSF


0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6260076
this will be a wise decission, because there you have a real transaction tracking
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6262226
It's good idea to use Interbase and be independent from BDE.

Anyway, starting transaction on BeforePost and commit it AfterPost is the way to avoid of transcation jam. Let say that transcation started when user press "Save" button and finished immediatly after data sended to database. Do you beleave that user able to switch to another form and press there "Save" button while data still not commited in first transaction? I think no.

Let look at idea to start transaction AfterInsert or AfterEdit dataset. Can you be sure that user doesnt change it's mind and will save entered data? But transaction will be started and takes server's resources to keep current version of database while user doesn't press "Save" or "Cancel" button.

So, this way will produce long transaction activity and may be a chance that it is fully unusual (user press "Cancel").

Just few words about transaction usage:-)

-------
Igor.
0
 
LVL 3

Author Comment

by:VSF
ID: 6365267
Thanks for your help and attention!

VSF
www.victory.hpg.com.br
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
This video discusses moving either the default database or any database to a new volume.
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…

760 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

22 Experts available now in Live!

Get 1:1 Help Now