gpt4 book ai didi

php - 未找到数据源名称,并且未指定默认驱动程序

转载 作者:IT王子 更新时间:2023-10-29 00:18:44 26 4
gpt4 key购买 nike

我需要帮助修复错误:SQLConnect 中的 SQL 状态 IM014SQLConnect 中的 SQL 状态 IM002

我运行相同的脚本,一个在 webserver/remote/ 上,另一个来自本地机器,试图访问同一个数据库,但我收到不同的错误消息。

当我从 web 服务器运行它时,我得到

SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQL

当我在本地机器上运行它时我得到了

[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

我在 php 脚本中使用以下代码连接到本地数据库

$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

我的ODBC.ini如下所示

[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

最佳答案

非常简单!

在服务器上:

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 位版本。

关于php - 未找到数据源名称,并且未指定默认驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26290532/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com