Dear All,
I want to make sure my table is really clean before importing data from excel. How do I truncate the table before import from excel.
Thanks for your advice.
Dear All,
I want to make sure my table is really clean before importing data from excel. How do I truncate the table before import from excel.
Thanks for your advice.
I'm writing this code to Row_Import event :
public function rowImport(&$row, $cnt)
{
//Log($cnt); // Import record count
//var_dump($row); // Import row
//return false; // Return false to skip import
$cek = ExecuteScalar("SELECT * FROM wbp WHERE nama = '" .$row["nama"]. "'"); //check if data exist
if (!empty($cek)) {
ExecuteUpdate("DELETE * FROM wbp WHERE nama = '" .$row["nama"]. "'"); //delete data if exist
return true; //running import
} else {
return true; //if not exist, running import
}
}
I got error messages --> Server error : 200
But if I refresh page, data successfully imported and List Page show correctly.
Where is the error in writing the code?
I change from this :
ExecuteUpdate("DELETE * FROM wbp WHERE nama = '" .$row["nama"]. "'");
to this :
ExecuteUpdate("DELETE FROM wbp WHERE nama = '" .$row["nama"]. "'");
and I still got same error massage : Server error : 200
noorshiam wrote:
$cek = ExecuteScalar("SELECT * FROM wbp WHERE nama = '" .$row["nama"]. "'"); //check if data exist
Double check your code above. If you use ExecuteScalar
, then you should SELECT field_name ...
and not SELECT * ...
.
Read Some Global Functions for more info.
I change my code to:
$cek = ExecuteScalar("SELECT nama FROM wbp WHERE nama = '".$row["nama"]. "'");
And still got same error --> Server error: 200