未找到数据源名称,且未指定默认驱动程序 [英] Data source name not found, and no default driver specified
问题描述
我需要帮助修复错误:SQLConnect 中的 SQL 状态 IM014
和 SQLConnect 中的 SQL 状态 IM002
.
我运行相同的脚本,一个在 webserver/remote/
上,另一个从本地机器尝试访问同一个数据库,但我收到不同的错误消息.
当我从 Web 服务器运行它时,我得到 p><块引用>
SQL 错误:[unixODBC][Driver Manager]未找到数据源名称,且未指定默认驱动程序,SQL 中的 SQL 状态为 IM002
当我在本地机器上运行它时我得到
<块引用>[Microsoft][ODBC 驱动程序管理器] 指定的 DSN 包含驱动程序和应用程序之间的架构不匹配
我在php脚本中使用以下代码连接本地数据库
$odbc['dsn'] = "SageLine50v19";$odbc['user'] = "Peac";$odbc['pass'] = "XXXX";$mysql['host'] = "localhost";$mysql['user'] = "root";$mysql['pass'] = "";$mysql['dbname'] = "sagetest";$mysql['idfield'] = "id";//第一步:连接源ODBC数据库if ($debug) echo "Connect to " .$odbc['dsn'] .' 作为 ' .$odbc['user'] ."\n";$conn = odbc_connect($odbc['dsn'], $odbc['user'], $odbc['pass']);如果(!$conn){die("连接到 ODBC 数据库时出错:" .odbc_errormsg());}//遍历每个表$allTables = odbc_tables($conn);$tablesArray = array();而 (odbc_fetch_row($allTables)) {if (odbc_result($allTables, "TABLE_TYPE") == "TABLE") {$tablesArray[] = odbc_result($allTables, "TABLE_NAME");}}//print_r($tablesArray);//列出所有表
我的ODBC.ini如下图
[ODBC 32 位数据源]manager=Sage Line 50 v16(32 位)t=SQL Server Native Client 10.0(32 位)s1=普及 ODBC 客户端接口(32 位)SageLine50v19=普及型 ODBC 客户端接口(32 位)[经理]Driver32=C:\Windows\SysWOW64\S16DBC32.dll[吨]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
很简单!
在服务器上:
SQL 错误:[unixODBC][Driver Manager]未找到数据源名称,且未指定默认驱动程序,SQL 中的 SQL 状态为 IM002
删除 USER 数据源名称,并将其定义为 SYSTEM 数据源名称.转到 -> 开始 -> 设置 -> 控制面板 -> 管理工具 ->数据源 (ODBC):- 用户 DSN : 删除指定的用户 DSN- 系统 DSN : 创建一个新的系统 DSN
否则尝试安装与本地安装相同的 32 位或 64 位版本.
本地:
[Microsoft][ODBC 驱动程序管理器] 指定的 DSN 包含驱动程序和应用程序之间的架构不匹配
32 位/64 位冲突 - 要么安装 32 位驱动程序版本,要么在 C:\Windows\SysWoW64\ 下使用/配置 32 位
尝试安装与本地安装相同的 32 位或 64 位版本.
I need help fixing an error: SQL state IM014 in SQLConnect
and SQL state IM002 in SQLConnect
.
I run the same script, one on webserver/remote/
and the other one from the local Machine trying to access the same database but i get different error message.
When i run it from web server i get
SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQL
where as when i run it on local machine i get
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
I used the following code in php script to connect to the Local database
$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
My ODBC.ini looks like below
[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
Very simple!
On server:
SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQL
Delete the USER data source name and define it as a SYSTEM data source name. Go to -> Start -> Settings -> Control Panel -> Administrative Tools -> Data Sources (ODBC): - User DSN : delete the specified User DSN - System DSN : create a new System DSN
Else try to install same 32bits or 64bits version as locally installed.
Locally:
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
32bit/64 bit conflict - either you install a 32bit driver version or you use/configure the 32bit under C:\Windows\SysWoW64\
Try to install same 32bits or 64bits version as locally installed.
这篇关于未找到数据源名称,且未指定默认驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!