Execute("SELECT * FROM qb_config ". #" WHERE tableid = ? ", array($_POST['tableid'])); #if ($rs->EOF) { # die('Error: Empty Data (EOF)'); #} #$odbc_dsn = $rs->fields['dsn']; #$sql = $rs->fields['sqlimport']; $odbc_dsn = $_POST['dsn']; $sql = $_POST['sqlimport']; if (empty($odbc_dsn)) { die("Error: Empty DSN"); } echo "DSN: ".$odbc_dsn."
"; $odbc =& ADONewConnection($odbc_dsn); if (!$odbc) { die($odbc->ErrorMsg()); } $odbc->SetFetchMode(ADODB_FETCH_ASSOC); echo "Connect: OK
"; echo "
"; $arrTables = $odbc->MetaTables(); if (!is_array($arrTables) || count($arrTables) == 0) { die("Error: Empty MetaTables
".$odbc->ErrorMsg()); } echo "MetaTables: ".count($arrTables)." tables => ".implode(", ", $arrTables)."
"; echo "
"; if (!$sql) { die("Error: Empty SQL Import"); } echo "SQL: ".$sql."
"; echo "
"; $rs = $odbc->Execute($sql); if (!is_object($rs)) echo $odbc->ErrorMsg(); else { $arr = array(); for ($i = 0, $n = $rs->FieldCount(); $i < $n; $i++) { $fieldobj = $rs->FetchField($i); $arr[] = $fieldobj->name; } $i = $rs->RecordCount(); echo "Found ".$n." fields => ".implode(", ", $arr)."
"; echo "Found ".$i." records.
"; if (!$rs->EOF) echo "First record: '".implode("', '", $rs->fields)."'
"; echo ""; } ?>