Connect Db After Instantiating A Class

davidvilla

Member
I am trying to connect a DB after a class is initiated and try to access it. But I am not able to. This is what I trying:

prog1.p:
--> connect mydb1
--> call prog2.p

prog2.p:
--> uses class mycls1
--> object for class mycls1

mycls1:
--> access mydb1 (as it is already connected in prog1.p)

Now in mycls1, I want to connect to a new db. So, I tried to call another program that will connect to this new db and then call another program to access the new db. But it does not work that way.

mycls1:
--> access mydb1
--> call prog3.p

prog3.p:
--> connect mydb2
--> call prog4.p

prog4.p:
--> access mydb2
Here I am not able to access mydb2.
I also tried to disconnect mydb1 in prog3, but still mydb1 is available in prog4.

Can you please help?

OE Version: 11.2
OS: Unix
 

tamhas

ProgressTalk.com Sponsor
You must connect or disconnect databases one level above where they are referenced.
 

davidvilla

Member
You must connect or disconnect databases one level above where they are referenced.
Yes, I understand that. But, it doesnt work that way, when I am already accessing a class and want to connect a new db and access the new db in a different (next) class.
 

tamhas

ProgressTalk.com Sponsor
Class or .p, you have to make the connection at one level and then descend to another level to use the connection. I know that is not what you want to do ... you want to make the connection and do the work in one class. but ABL has never worked that way.
 

davidvilla

Member
Class or .p, you have to make the connection at one level and then descend to another level to use the connection. I know that is not what you want to do ... you want to make the connection and do the work in one class. but ABL has never worked that way.
sorry.. i replied to your comment in community.progress.com

From a class, if I call a .p to connect a db and then call another .p to access the db, it doesnt work.

prog1 (connect db1) --> prog2.p (use class mycls1) --> class mycls1 (access db1) --> prog3.p (connect db2) --> prog4.p (access db2)
Not able to access db2 in prog4.p, eventhough db2 is connected one level up in prog3.p
Is my question clear?
 
Last edited:
Top