We help IT Professionals succeed at work.

Distributed DB

h_mohsenian
h_mohsenian asked
on
Medium Priority
334 Views
Last Modified: 2010-04-06
Dear Friends,

I need a Distributed DB :

suppose that I have 3 programs in 3 computers ( all in  a LAN ) with 3 IP addresses. I need that these 3 programs use the same db . It means they should be able to Read & Write the DB fields. and Also if one of them changed the DB , others Detect it ( by Event ) .
for Example if  the db file called : ?mydb.db? :
1-     program 1,2,3  , should be able to change the ?mydb.db? fields ( all of them ).
2-    if one of them changed a field , others detect it by an event

I know that we Can Use TClientSocket & TServerSocket Components for Communicating between these programs  ( and already I had done it by SendText routine) . but It is not perfect for my work.

Please show me a complete answer ( it is urgent for me ) and even if you want please send me the program code to my email : mohsenianrad@scribe.com  ( if you did it , please say it to me here in Ex.Ex comments )

thanks a lot & best wishes for you
Hamed
Comment
Watch Question

Commented:
The perfect solution for your problem is to use a true SQL Server (desktop databases such as Access and dBASE are not suited for real-time transactions).  I recommend InterBase Server and use TIBEvents to monitor the database changes. You will have to use POST_EVENT in your table triggers.

Example:
(InterBase)
Trigger for table UserList (After Insert)
begin
  post_event('new_user');
end
Trigger for table UserList (After Update)
begin
  post_event('user_account_update');
end

(Delphi)
procedure TForm1.IBEvents1EventAlert(Sender: TObject; EventName: String; EventCount: Integer; var CancelAlerts: Boolean);
begin
  if EventName = 'new_user' then
    Action4NewUser;
  if EventName = 'user_account_update' then
    Action4UserAccountUpdate;
end;

Author

Commented:
hi my friend,

Sorry for my late answer.

thanks alot for your help,

about InterBase Usage. unfortunately I have not ever use Interbase :-( . and more unfortunately I have not enouph time for my present need to learn Interbase too.

If you could send me a Sample Program to my email.

thanks again
hamed

Commented:
HI,
Use DCOM.
Sincerely,
Nestorua.

Author

Commented:
hi nestorua ,

Can You Tell me an Example of DCOMConnection ?

a little one , which just send and recieve Messages like TServerSocket & TClienSocket

Thanks
hamed
Commented:
HI, Hamed,
To create a little DCOM program to send and receive messages
you have to make the following steps:
Creating Server Program:
1.Create new Application.
2.Put an Edit on the main form.
3.Add a TAutomation Object to this Application with
the interface named ITest.
4.Define a new method in the ITest named
procedure StringReceived(const S: WideString);
5.In the file ..._TLB.pas implement it as follows:
procedure StringReceived(const S: WideString);
begin
FormMain.Edit1.Text:=S;
end;6.Register your Server (just launch it once) locally
and on the remote machine (and put it on the remote machine).
Creating Client Program:
1.Create new Application.
2.Put an Edit on the main form.
3.Import a Type Library from the Server.
4.In public part of the form define a variable
Test of the Type ITest.
4.Define a Edit1KeyDown method as follows:
procedure Edit1KeyDown(...);
begin
if Key=VK_RETURN
 then
  begin
   if FTest=NIL
    then Test:=CoTest.CreateRemote(NameOfYourRemoteMachine);
   FTest.StringReceived(Edit1.Text);
  end;
end;
5.Launch the Client Program on the remote machine
and input some text in the Edit1 and press "Enter".
You'll see the Server Prog with your Text in its Edit Component.
Now launch the Client Prog on the Local machine and
input some other text in the Edit1 and press "Enter".
The Text of the Server Program Edit now changes to this
new one.

Commented:
Hi, Hamed,
I already sent you yesterday the comment how to create the example you want, but don't see it now.
Don't know why?
Are those answers 'visible' after a couple of days?
Sincerely,
Nestorua.

Author

Commented:
hi nestorua ,

I saw your comment and thanks for it. but I have to test it on network and I can do it tomarrow . but I check your code and searched for TAutomation but I saw that it is a delphi 2 class and it is not in Delphi 5 ( I use it now )
as I said I will test your Code soon BUT if you could please tell me an Example with TDCOMConnection. Can You Tell me it ?

> Are those answers 'visible' after a couple of days?

Yes The Comments are visible always. but as I said sorry for my not fast replying.

I use Ex.Ex site not only as Programming Exchange but also I use it for finding new friend because we have a common field in our life which is computer programming world. where do you come from ? and how old are you ? Can You Tell me your email for extra friendly talking ?

take care,
hamed

Commented:
HI, Hamed,
I wrote you using Delphi5.
TAutomation Object is in DELPHI5
(New\ActiveX tab).
My E-MAIL:
matmod@franko.lviv.ua
Sincerely,
Nestorua.

Author

Commented:
hi nestorua ,

I am sure you are right about TAutomation but

1. I have not NewActiveX tab :-( . I just have ActiveX tab and it has not TAutomation or any retalet Object at all :-(

2. I have never see the TAutomation therefore when you told me to use it I saw the Delphi Help. infact there is not TAutomation titled Subject in INDEX Tab in Help . after that I searched in FIND tab for it and there was just one page which was about

var Automation : TAutomation

Automation is for backward compatibility with Delphi 2.0.

and I did not understand so much , therefor I told you it is for Delphi 2.

but now I guess you are right but It seems my Delphi is not a complete version or maybe the NewActiveX tab is not a base Tab and infact it must be an Extra tab.

therefor as a complte result I can say It is so better for me to use DCOMConnection :-) , Am I Right ? ;-)

-------------------

I saw your Email Site. ( the University in  Ukrain ) , I guess you are Ukrainian . Am I right ?

But About me ( I am not sure it is interesting for you because you did not ask it from me ;-)  ) BUT :

I am 22 years old. an senior student of Electrical Control Eng. Now I am working on my BS project . it is about Designing a Distributed Automatin System for a Textile Factory and the present question is about my project.

take care
hamed

Commented:
HI, Hamed,
Yes I am Ukrainian, from Ukraine, Lviv,
Franko Lviv University, Department of Mathematics.
Sure, I am interested in where are you from.
When I wrote New>ActiveX, I meant to press "New", then choose "ActiveX" tab, then choose "Automation Object" from
the corresponding Sheet (there are eight of the available
choices). And all of what I am saying is in DELPHI 5.
Sincerely,
Nestorua.




Author

Commented:
hi nestorua ,

thanks for your help . I asked a new question for your point by " For nestorua " title,

please see this address :

http://www.experts-exchange.com/jsp/qYourQuestion.jsp

I will send you an email soon. Just one thing. I am from Iran. ( we are a common situation in football : play off games )
h_mohsenian:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.