我正在尝试通过ODBC连接到数据库,但通过Google/ internet找不到任何帮助。
我们的ERP使用OMNIS作为框架,它提供了一个ODBC驱动程序,用于在程序外部查询OMNIS的专有数据库。我已经创建了驱动程序和DSN,但我无法开始使用PHP操作数据或发送查询。
驱动程序在ODBC连接管理器中显示为"OMNIS ODBC驱动程序“-我已经尝试了许多连接字符串,但似乎无法使其运行。
数字源码位于C:\Test.dsn。该驱动程序再次显示为OMNIS ODBC驱动程序。任何帮助都是非常非常感谢的。
发布于 2011-04-27 03:11:38
我最终开放了将数据库克隆到SQL并使用该方法。要让OMNIS ODBC驱动程序正常工作实在是太痛苦了。
发布于 2011-06-09 22:11:49
答案:
这些说明假定已经在主机服务器上设置了Apache web服务器。
操作系统: Windows Server2003Web服务器:Apache2 (WAMP www.wamp.com)
用于Windows的Omnis ODBC驱动程序非Unicode驱动程序(http://www.tigerlogic.com/tigerlogic/omnis/download/tools.js下载并安装
使用以下示例代码测试数据连接。
<?php
/*My data source is named PFDSN, so that is what I will be using in this example
Make sure you use the exact name of the data source created in step 2.
*/
$conn = odbc_connect('PFDSN',' ',' '); //the connection to the data file
$sql = 'select * from INVOICES'; //query string
$result = odbc_exec($conn,$sql); //execute the query
$while($data[] = odbc_fetch_array($result)); //loop through the result set
odbc_free_result($result); //unallocate the result set
odbc_close($conn); //because this is good practice
print_r($data);
?>
保存并关闭该文件。导航到http://localhost/odbc_test.php (或文件所在的任何位置)。
如果连接成功,该页面将显示从invoices表中提取的所有数据的转储。
如果不起作用,请检查以确保连接字符串中包含正确的DSN名称。
如果连接字符串是正确的,但仍然不起作用,则PHP可能没有配置ODBC模块。但是,您应该注意到,由于PHP5(在Windows中)在缺省情况下启用了ODBC模块。
不幸的是,在撰写本文时,Tiger Logic还没有提供Linux/Unix ODBC驱动程序。希望他们能醒悟过来,意识到Windows很烂。
结束了。
发布于 2012-01-12 15:57:50
我能够使用以下DSN进行连接:
odbc:DRIVER=OMNIS;DataFilePath=C:\import\average.df1
https://stackoverflow.com/questions/2960293
复制相似问题