简体   繁体   English

如何使用 PHP 连接到 Sage 50 ODBC 数据库

[英]How to Connect to Sage 50 ODBC Database with PHP

I'm attempting to export data from Sage 50 database.我正在尝试从 Sage 50 数据库中导出数据。 I have managed to create a connection to the database however whenever I perform a query I have the following error message.我设法创建了到数据库的连接,但是每当我执行查询时,我都会收到以下错误消息。

Warning: odbc_exec(): SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH : [S1C00] Driver not capable in C:... on line 4警告:odbc_exec():SQLColAttribute 无法处理SQL_DESC_OCTET_LENGTH :[S1C00] 驱动程序不支持 C:... 第 4 行

I have Attempted to change the cursor to SQL_CUR_USE_CODE as suggested on PHP.net我已尝试按照PHP.net 上的建议将光标更改为SQL_CUR_USE_CODE

I am also sure it is connecting as when I enter a table name that doesn't exist then I am receiving this error.我也确定它正在连接,因为当我输入一个不存在的表名时,我收到了这个错误。

Warning: odbc_exec(): SQL error: Table not found, SQL state S0002 in SQLExecDirect in C:... on line 4警告:odbc_exec():SQL 错误:找不到表,SQL 状态 S0002 在 C:... 中的 SQLExecDirect 中的第 4 行

$conn = odbc_connect("TestDB", "Manager", "", SQL_CUR_USE_ODBC);
$sql="SELECT * FROM STOCK"; 
$result=odbc_exec($conn,$sql);

Thanks in advance提前致谢

I was having a similar issue with ac# application, but my solution may have some pertinence here and I hate to see someone go through the stress that I did.我在 ac# 应用程序中遇到了类似的问题,但我的解决方案在这里可能有一些相关性,我讨厌看到有人经历我所做的压力。 Here's what I did to fix my issue:这是我为解决问题所做的工作:

  1. In the ODBC Data Source Administrator, select your Pervasive ODBC Client Interface在 ODBC 数据源管理器中,选择 Pervasive ODBC Client Interface
  2. Under Data Options select a database name associated with the data source of your CrystalReports.udl file.在数据选项下,选择与 CrystalReports.udl 文件的数据源关联的数据库名称。 Make sure the Dictionary location is the Data directory for your company.确保字典位置是您公司的数据目录。
  3. Make sure your select statement queries a table that are allowed by the crystal report eg Address, Audittr, etc. since not all tables can be queried through the Crystal reports.确保您的选择语句查询 Crystal 报告允许的表,例如 Address、Audittr 等,因为并非所有表都可以通过 Crystal 报告进行查询。

Hope that helps!希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM