The attached page currently work fine, but it has the problem of failing to insert the record sometimes especially when more than 50 people access the page at the same time..
What the attach script does is to count the database table using a loop. This is not very effective since most times it fails to insert. The two database tables currently have more than 80,000 records and counting individual record to determine where to insert the next record may be the reason why it fails sometimes to insert.
Someone suggested using a GetRow() function to determine when to insert the next record.
Please consider the best approach and ensure that it is one record that has to be inserted at a time so that it will never fail to insert.