如何纠正此错误:未找到数据源名称,并且未指定默认驱动程序 [英] How can I correct this error: Data source name not found and no default driver specified
问题描述
我有一个运行在Windows服务器上的网站,它的工作完全正常。我试图在我的本地主机复制,但我得到的错误:
I have a website that runs in Windows server, and it works perfectly fine. I tried to make a copy in my localhost but I get the error:
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\xampp\htdocs\tdms\webfolders\secured\db_fns.php on line 29
Could not connect to database server
第29行包含: p>
line 29 contains:
function fgsdb_connect()
{
$a=array();
$retvar=0;
$result = odbc_connect('FGS','tdms','tdms358',SQL_CUR_USE_ODBC); //---->line 29
if (!$result) // cannot establish connection to database
throw new Exception('Could not connect to database server');
else // connection to database has been established
return $result;
}
我真的是odbc的新手。该网站是用PHP和我在MySQL中使用的数据库写的。虽然我想,它试图连接的数据库是一个微软访问MDE文件。 (我检查在Windows服务器的网站。)我该怎么办?对不起,但我真的
I am really new to odbc. the website is written in php and the database that i use in mySQL. though i figured that the database that it is trying to connect is a microsoft access MDE file. (i checked in the site in windows server.) What should i do? im sorry but i am really
推荐答案
这可能是设置ODBC数据源的快捷方式指向32位数据源, 。
It's likely the shortcut for setting ODBC data sources is pointing to the 32bit data sources instead of 64bit.
转到控制面板 - >管理工具 - >选择数据源(ODBC) - >然后右键单击该文件 - >转到属性 - >在快捷方式标签中更改路径
Go to control panel -> administrative tools --> select data sources(ODBC) --> then right click on that file --> go to properties --> in the shortcut tab -> change the path from
%windir%\System32\odbcad32.exe
到
%windir%\SysWOW64\odbcad32.exe
并进行连接。
如果它不工作,尝试连接到ODBC与一个句子,如下:
If it doesnt work, try to connect to the ODBC with a sentence like this:
$conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\YourFolder\YourFile.mdb",'Youruser', 'YourPassword');
最后两次离开,只是''如果你没有任何用户或密码
The last 2 leave then just the the '' if you dont have any user or password
这篇关于如何纠正此错误:未找到数据源名称,并且未指定默认驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!