I made an application that creates scratch tables (does a couple of cross tabs and combines them, etc.) The code I use for this is:
The tables are erased and dropped from the database when I run this from the developer version but when I run it from the runtime I get a strange thing happening. The tables seem to be erased but still show up with an error (apparently not dropped.) It looks like this (see attachment):
You can't delete tables while accessing the database from the runtime. Is this the problem? Is there some workaround that I can do to make these tables disappear?
Thanks,
Larry
Code:
'---------------------------------------------------------------------------- 'THE CODE BELOW REMOVES THE SCRATCH TABLES FROM 'THE DATABASE. THEY MUST BE ERASED AND THEN REMOVED FROM THE LISTING '---------------------------------------------------------------------------- 'xtabcost 'xtabunit 'xtabcostunit 'xtabcostunitar 'error_costwithoutar ' 'Designating the file names with exact locations. fileremname1 = dbfdir+"xtabcost"+".dbf" fileremname2 = dbfdir+"xtabunit"+".dbf" fileremname3 = dbfdir+"xtabcostunit"+".dbf" fileremname4 = dbfdir+"xtabcostunitar"+".dbf" fileremname5 = dbfdir+"error_costwithoutar"+".dbf" 'The code stops running if for some reason the first file name doesn't exist if fileremname1 = "" then end end if 'Erase the first file table.erase(fileremname1, .T.) 'Sets a variable to see if the erase of costxtab was successful result = file.exists(fileremname1) 'If the was erased successfully then the table is dropped from the database. 'If not then an error pops up. if result = .F. then FILE_DROP_FROM_DB(fileremname1) else ui_msg_box("Erase:Error", fileremname1 + "Erase failed.") end if 'The code stops running if for some reason the second file does not exist if fileremname2 = "" then end end if 'Erase the second file table.erase(fileremname2, .T.) 'Sets a variable to see if the erase of lbrxtab was successful result = file.exists(fileremname2) 'If the was erased successfully then the table is dropped from the database. 'If not then an error pops up. if result = .F. then FILE_DROP_FROM_DB(fileremname2) else ui_msg_box("Erase:Error", fileremname2 + "Erase failed.") end if 'Erase the third file table.erase(fileremname3, .T.) 'Sets a variable to see if the erase of lbrxtab was successful result = file.exists(fileremname3) 'If the was erased successfully then the table is dropped from the database. 'If not then an error pops up. if result = .F. then FILE_DROP_FROM_DB(fileremname3) else ui_msg_box("Erase:Error", fileremname3 + "Erase failed.") end if 'Erase the fourth file table.erase(fileremname4, .T.) 'Sets a variable to see if the erase of lbrxtab was successful result = file.exists(fileremname4) 'If the was erased successfully then the table is dropped from the database. 'If not then an error pops up. if result = .F. then FILE_DROP_FROM_DB(fileremname4) else ui_msg_box("Erase:Error", fileremname4 + "Erase failed.") end if 'Erase the fifth file table.erase(fileremname5, .T.) 'Sets a variable to see if the erase of lbrxtab was successful result = file.exists(fileremname5) 'If the was erased successfully then the table is dropped from the database. 'If not then an error pops up. if result = .F. then FILE_DROP_FROM_DB(fileremname5) else ui_msg_box("Erase:Error", fileremname5 + "Erase failed.") end if ui_dlg_box("Files erased and dropped from the database",fileremname1+crlf()+fileremname2+crlf()+fileremname3+crlf()+fileremname4+crlf()+fileremname5+crlf(2)+"Browse the data to make sure you've done it correct"+crlf()+"Please backup this data!")
You can't delete tables while accessing the database from the runtime. Is this the problem? Is there some workaround that I can do to make these tables disappear?
Thanks,
Larry
Comment