Solved

MDI Forms and Paradox over Network

Posted on 2001-07-05
19
270 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
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 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

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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 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