连接 Visual FoxPro9 表时 php5 odbc_connect() 函数错误

发布于 2024-10-30 02:21:26 字数 1334 浏览 1 评论 0 原文

我在 Ubuntu10.10 服务器上运行 php5,其中已经安装了 unixODBC 和 php5-odbc 软件包。我在连接过程中不断收到错误 - 代码:

$data_source = 'DRIVER={Microsoft dBASE Driver (*.dbf)};Data Source=//128.251.xxx.xxx/lv_apps/AppsLON/CData/dbf/cdma';"", "");
$conn = odbc_connect($data_source, "", "");
if (!$conn)
    exit("Connection Failed: " .$conn );

错误消息:

1 Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/vfptest.php on line 6 

我向两个文件添加了 extention=dbase.soextention=odbc.so/ etc/php5/apache2/php.ini/etc/php5/cli/php.ini 并重新编译 php 安装:

sudo ./configure --prefix=/usr --enable-dbase=shared --with-unixODBC

我还转到了 unixODBC 和 pecl单独安装 unixODBC 和 dbase 库没有成功。

我还找到了这个链接: http://www.devlist.com/ConnectionStringsPage.aspx 其中指出,为了创建到 FoxPro 数据库的 ODBC 连接,我使用了以下行:

Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=c:\demo.dbc;Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO 

但这对我来说仍然不起作用;可能是因为我没有安装 Visual FoxPro 驱动程序或我的 odbc.ini 文件指向驱动程序路径...但我不知道。

I'm running php5 on Ubuntu10.10 server where the unixODBC and php5-odbc packages have already been installed. I keep getting an error during the connection process - code:

$data_source = 'DRIVER={Microsoft dBASE Driver (*.dbf)};Data Source=//128.251.xxx.xxx/lv_apps/AppsLON/CData/dbf/cdma';"", "");
$conn = odbc_connect($data_source, "", "");
if (!$conn)
    exit("Connection Failed: " .$conn );

error message:

1 Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/vfptest.php on line 6 

I added extention=dbase.so and extention=odbc.so to both files: /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini and re-compiled the php install with:

sudo ./configure --prefix=/usr --enable-dbase=shared --with-unixODBC

I've also gone to unixODBC and pecl to install the unixODBC and dbase libraries separately with no luck.

Also I found this link: http://www.devlist.com/ConnectionStringsPage.aspx
where it is stated that in order to create an ODBC connection to a foxpro database I use the line:

Driver={Microsoft Visual FoxPro Driver};SourceType=DBC;SourceDB=c:\demo.dbc;Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO 

this still did not work for me however; probably because I do not have the visual foxpro driver installed or my odbc.ini file pointing to the driver path...but I don't know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

美羊羊 2024-11-06 02:21:26

简而言之 - odbc_connect() 需要; ODBC 数据源名称 (DSN)、用户名和密码按照 --

http://php.net/manual/en/function。 odbc-connect.php

据我所知,Linux 没有 VFP ODBC 驱动程序,因此您很可能需要使用 ODBC 桥解决方案,例如 -

http://uda.openlinksw.com/odbc-odbc-mt/

它具有客户端/服务器架构 --

Linux 客户端 --
PHP ODBC 应用程序
OpenLink 通用 ODBC 驱动程序(瘦多层 ODBC 客户端)

Windows 服务器 --
OpenLink 请求代理(多层服务器)
OpenLINK Agent for ODBC(多层服务器)
Fox Pro ODBC DSN(预配置)
Fox Pro 文件...

我希望这有帮助吗?

In short - odbc_connect() takes; an ODBC Data Source Name (DSN), Username & Password as per --

http://php.net/manual/en/function.odbc-connect.php

As far as I am aware there is no VFP ODBC driver for Linux so you will, most likely, need to employ an ODBC Bridge solution like -

http://uda.openlinksw.com/odbc-odbc-mt/

This has a client/server architecture --

Linux client --
php ODBC Application
OpenLink Generic ODBC Driver (thin multi-tier ODBC client)

Windows server --
OpenLink Request Broker (Multi-tier server)
OpenLInk Agent for ODBC (Multi-tier server)
Fox Pro ODBC DSN (pre configured)
Fox Pro files...

I hope this helps?

水染的天色ゝ 2024-11-06 02:21:26

MSDN 网络

您发布的驱动程序行是“...版本高于 6 的 VFP 表不支持 ODBC 连接字符串。”

Check out the very bottom of this thread on the MSDN network

the driver line you have posted is "...an ODBC connection string which is not supported for VFP tables having a version later than 6."

不必了 2024-11-06 02:21:26

虽然不熟悉linux连接VFP,但是,此类VFP的odbc连接连接到一个PATH,而不是一个特定的表。一旦与 PATH 的连接有效,您就可以查询该位置中的任何 .DBF 表。

虽然我无法回答您的具体连接信息,但我找到了此链接

http: //www.phpfreaks.com/forums/index.php?topic=296832.0

显示连接到数据源...注意它标识 'DRIVER={Microsoft dBASE Driver (*.dbf)};datasource= /home/dir/file.dbf;'使用...您可能必须结合使用此驱动程序和路径信息(我仍然会先尝试不使用特定的 .dbf 文件)。

希望这有帮助..

Although not familiar with linux connecting to VFP, however, odbc connections for such VFP connect to a PATH, not a specific table. Once the connection to the PATH is valid, THEN you can query any .DBF table IN that location.

Although I can't answer your specific connection info, I've found this link

http://www.phpfreaks.com/forums/index.php?topic=296832.0

that shows connecting to a datasource... notice its identifying the 'DRIVER={Microsoft dBASE Driver (*.dbf)};datasource=/home/dir/file.dbf;' used... You'll probably have to hit a combination of this driver and pathing info (I'd still try WITHOUT the specific .dbf file first).

Hope this helps..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文