I have 2 of the same databases installed in 2 different locations on the machine one is c:\housing and the other is c:\housing2 I use local tables to store data pulled from sql server so I run a script to delete old data and pack tables when a new record is pulled. I'm having a problem with pack tables when I have both of the databases open because they have the same name alpha wants to try and pack tables by reference name and I'm getting unable to pack because table is in use error. I kinda understand why this happens so I modified my code to try and pack just the tables for the database calling the script but still getting errors. Is there a way to work around this problem? My code is posted for review.
Code:
'Date Created: 03-Feb-2017 05:08:25 PM 'Last Updated: 23-Oct-2018 12:58:17 AM 'Created By : Hubby 'Updated By : steve dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlclientd.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlmiti_notes.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlenrol_notes.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlenroll.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlfinance.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlccb_info.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqldocs.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqlintake.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"sqldeals.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"paytoday.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"master.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if delete tname delete rtbl delete tname delete rtbl dim shared rtbl as p dim shared tname as c tname=a5.get_path() + chr(92)+"rep_payout.dbf" rtbl = table.open(tname) dim shared tbl as P query.filter = "" query.order = "Recno()" qry_ca_cust = rtbl.query_create() 'Delete all records in current query by omitting the optional filter expression if table.in_use(tname)=.F. rtbl.delete_range() rtbl.pack() rtbl.close() end if
Comment