Php JQGrid与microsoftsqlserver

Php JQGrid与microsoftsqlserver,php,jquery,sql-server,jqgrid,jqgrid-php,Php,Jquery,Sql Server,Jqgrid,Jqgrid Php,我正在尝试使用SQL Server实现这一令人敬畏的功能。我已经安装了PDO,因为我在MS Access的其他地方使用它-我想我现在已经在sql server 2008中安装了它。以下是我的连接方式: define('DB_DSN',"odbc:Driver={SQL Server};Server=MyInstance;Database=table1;"); define('DB_USER', ''); define('DB_PASSWORD', ''); // include the jq

我正在尝试使用SQL Server实现这一令人敬畏的功能。我已经安装了PDO,因为我在MS Access的其他地方使用它-我想我现在已经在sql server 2008中安装了它。以下是我的连接方式:

define('DB_DSN',"odbc:Driver={SQL Server};Server=MyInstance;Database=table1;");
define('DB_USER', ''); 
define('DB_PASSWORD', '');

// include the jqGrid Class
require_once "php/jqGrid.php";
// include the PDO driver class
require_once "php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
$tsql = 'SELECT * FROM Trt';
// Write the SQL Query
$grid->SelectCommand = $tsql;
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('report-creator.php');

// Set grid caption using the option caption
$grid->setGridOptions(array(
    "caption"=>"Report",
    "rowNum"=>10,
    "sortname"=>"OrderID",
    "hoverrows"=>true,
    "rowList"=>array(10,20,50),
    ));

$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true));
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
我得到这个错误:

    Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IM001]: Driver
 does not support this function: driver doesn't support meta data' in  
C:\wamp\www\webs\tgd\edh\php\jqGridPdo.php(1) : eval()'d code:1 Stack trace: #0 
C:\wamp\www\webs\tgd\edh\php\jqGridPdo.php(1) : eval()'d code(1): PDOStatement-
    >getColumnMeta(0) #1 C:\wamp\www\webs\tgd\edh\php\jqGrid.php(1) : eval()'d code(7):  
jqGridDB->getColumnMeta(0, Object(PDOStatement)) #2 C:\wamp\www\webs\tgd\Front- End\report-
creator.php(31): jqGridRender->setColModel() #3 C:\wamp\www\webs\tgd\Front- End\view-
report.php(123): require_once('C:\wamp\www\web...') #4 {main} thrown in  
C:\wamp\www\webs\tgd\edh\php\jqGridPdo.php(1) : eval()'d code on line 1
我很感激任何帮助,我就是不明白这个问题。我已经把它缩小到这个函数:$grid->SelectCommand-如果我删除这个函数,就不会发生错误,但是我不能没有它,因为这是我查询数据库的t-sql的地方

我可以使用PDQ->query'SELECT*fromtable1'查询SQLServerMySQL

谢谢大家


请注意:为了隐私,我编辑了表名和文件路径:

看起来jqGrid使用getColumnMeta函数来枚举列,但是这个函数由几个驱动程序实现——在本例中,是MSSQL驱动程序


请参阅上面链接中的示例以测试getColumnMeta是否有效。

我为Trirand公司工作,该公司是开发人员jqGrid-ASP.NET团队,不幸的是,我不能在PHP方面提供太多帮助,但我建议在我们自己的论坛上也发布同样的问题:

在那里你会发现一个PHP jqGrid论坛,你会得到我们PHP团队的及时回复。同时,我会给他们写一封电子邮件,并请他们在这里提供帮助,但以防万一,在那里发帖会保证给你一个答案

干杯, 瘤胃斯坦科夫
Trirand Inc

我无法解决这个问题,因此我切换到另一个类,该类是由JQGrid人员编写的,它使用了来自Microsoft的PHP驱动程序。这解决了我的问题,希望它能帮助别人。

我在你粘贴的代码块中没有看到SelectCommand。由于这是令人不快的代码,如果您将其重新添加到中,将会很有帮助。对不起,我已将此添加到中。