connect db from a .p program

greeshma

Member
Sorry for editing post.
I want to connect db from a .p program.The program code and pf value is given below.

TEST.P
def var v-stk as char no-undo.
v-stk = "db\dsCHK.db" .
if not connected ("dsCHK") then
connect value(v-stk) -pf db\pf_files\dsCHK.pf .
if not connected("dsCHK") then do:
message "Cannot connect to dsCHK database"
view-as alert-box.
quit.
end.
else message "connected db " view-as alert-box.
run chng.p

dsCHK.pf
-s 63
-D 200
-yy 1920
-d mdy
-T c:\temp
-B 6000
-L 5000
-db d:\apps\dts\chk\dsSHP\db\dsCHK.db
-ld dsSHP
-db d:\apps\dts\chk\dsSHP\db\dspic.db

When i run this program i am getting connected to dsCHK.The program chng.p contains code find first customers no-lock .
Then i am getting error Table customers is in database dsSHP and dsCHK (425)
Unknown or ambiguous table customers. (725)

But when i tried to connect from desktop icon , with this same pf file ,i am not getting this error.
dsSHP is the logical name for db dsCHK , i cant remove -ld parameter,because that will affect some other programs..

Please advice me,
 
Hi, You are connecting to the same DB with different logical name, try it:

Code:
def var v-stk as char no-undo.
/*
v-stk = "db\dsCHK.db" .
*/
if not connected ("[B]dsCHP[/B]") then
   connect [B]/*value(v-stk)*/[/B] VALUE("-pf db\pf_files\dsCHK.pf") .
if not connected("[B]dsCHP[/B]") then do:
   message "Cannot connect to dsCHP database"
                view-as alert-box.
   quit. 
end.
else message "connected db " view-as alert-box. 
run chng.p

Regards.
 
Back
Top