You can get rid of this code:
$wa_startindex = 0;
while(!$rsADHOC1->atEnd()) {
$wa_startindex = $rsADHOC1->Index;
$rsADHOC1->moveNext();
$totalRows += 1;
}
$rsADHOC1->moveFirst(); //return RS to first record
unset($wa_startindex);
and just use:
$rsADHOC1->TotalRows;
It looks like it should insert.
You can check if an insert took place with:
$isgood = ($InsertQuery->InsertID!=0);