Ho bisogno di aiuto per correggere un errore: SQL state IM014 in SQLConnect
e SQL state IM002 in SQLConnect
.Nome origine dati non trovato e nessun driver predefinito specificato
Eseguo lo stesso script, uno su webserver/remote/
e l'altro dal computer locale che tenta di accedere allo stesso database ma ottengo un messaggio di errore diverso.
quando l'eseguo dal web server ottengo
SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQL
dove come quando ho eseguito sulla macchina locale ottengo
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
ho usato il seguente codice in script php per connettersi al Database locale
$odbc['dsn'] = "SageLine50v19";
$odbc['user'] = "Peac";
$odbc['pass'] = "XXXX";
$mysql['host'] = "localhost";
$mysql['user'] = "root";
$mysql['pass'] = "";
$mysql['dbname'] = "sagetest";
$mysql['idfield'] = "id";
// Step 1: Connect to the source ODBC database
if ($debug) echo "Connect to " . $odbc['dsn'] . ' as ' . $odbc['user'] . "\n";
$conn = odbc_connect($odbc['dsn'], $odbc['user'], $odbc['pass']);
if (!$conn) {
die("Error connecting to the ODBC database: " . odbc_errormsg());
}
// loop through each table
$allTables = odbc_tables($conn);
$tablesArray = array();
while (odbc_fetch_row($allTables)) {
if (odbc_result($allTables, "TABLE_TYPE") == "TABLE") {
$tablesArray[] = odbc_result($allTables, "TABLE_NAME");
}
}
//print_r($tablesArray); // to list all tables
mio ODBC.in I si presenta come di seguito
[ODBC 32 bit Data Sources]
manager=Sage Line 50 v16 (32 bit)
t=SQL Server Native Client 10.0 (32 bit)
s1=Pervasive ODBC Client Interface (32 bit)
SageLine50v19=Pervasive ODBC Client Interface (32 bit)
[manager]
Driver32=C:\Windows\SysWOW64\S16DBC32.dll
[t]
Driver32=C:\Windows\system32\sqlncli10.dll
[s1]
Driver32=C:\Program Files (x86)\Pervasive Software\PSQL\bin\w3odbcci.dll
[SageLine50v19]
Driver32=C:\Program Files (x86)\Pervasive Software\PSQL\bin\w3odbcci.dll
La mancata corrispondenza dell'architettura DSN è dovuta al fatto che il controllo dell'applicazione e del guidatore del driver differiscono, si sta tentando di utilizzare un driver a 32 bit con un'applicazione a 64 bit o viceversa. Dovrai abbinarli affinché tutto funzioni correttamente. Sul tuo computer locale, se stai utilizzando un driver a 32 bit, passa a uno a 64 bit e riprova. Sul server, hai installato il driver e il DSN? – KylePorter
@KylePorter grazie per la risposta non sono sicuro di DSN ma so che il mio webhost ha aggiunto l'estensione "odbc". controllerò con loro il DSN – Keven
Non è sufficiente avere solo il driver ODBC installato, è necessario anche creare un DSN sul server a cui connettersi, lo stesso del tuo computer locale. Se stai distribuendo lo stesso codice, devi assicurarti che il DSN sia impostato in modo identico a quello che hai localmente. – KylePorter