I can’t seem to get the MSSQL connector working for a simple grid. It fails with a 500 status code returned. Would someone please tell me why?
Here’s the grid webpage code:
[code]
[/code]
Here’s the ‘testconnector.php’ file called by the load method of the grid webpage:
[code]<?php
require_once(“/dhtmlxSuite/dhtmlxConnector/codebase/grid_connector.php”); //<- works
require_once(“/dhtmlxSuite/dhtmlxConnector/codebase/db_mssql.php”); //<- works
$res=mssql_connect("MySQLServer\MySQLServerInstance","myDomain\myLogIn","myPassword",false); //<-- fails here with 500 status code returned.
mssql_select_db("myDatabase");
$grid = new GridConnector($res,"MsSQL");
$grid->render_table("myTable","EmpID","EmpID,Email");
require_once("/dhtmlxSuite/dhtmlxConnector/codebase/db_sqlsrv.php");
...
$grid = new GridConnector($res,"SQLSrv");
(2) It may be so. The mssql driver was replaced with sqlsrv in latest php builds, so it may require rebuilding php to get mssql enabled db_sqlsrv.zip (1.06 KB)
//require_once("/dhtmlxSuite/dhtmlxConnector/codebase/db_mssql.php");
require_once("/dhtmlxSuite/dhtmlxConnector/codebase/db_sqlsrv.php"); //<- replaces db_mssql
require_once("/dhtmlxSuite/dhtmlxConnector/codebase/grid_connector.php");
$serverName = "CH-SQL-6\Pentamation_rpt";
$uid=file_get_contents("C:\inetpub\wwwroot_DEV\uid.txt");
$pwd=file_get_contents("C:\inetpub\wwwroot_DEV\pwd.txt");
$connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>"COF_finplus_Dev", "LoginTimeout"=>15); // <- SS authentication
$res = sqlsrv_connect( $serverName, $connectionInfo); // <- SS authentication
if( $res )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
$grid = new GridConnector($res,"SQLSrv");
$grid->render_table("proj_title","code","lvl,title"); // <- displays XML via dhtmlxError.catchError
/* Close the connection. */
sqlsrv_close( $res);
echo “Connection closed.\n”;
?>[/code]
[code]And here is my HTML code:
[/code]
I am getting back data from the database, but it doesn’t appear inside the grid. Instead, it is displayed through a popup generated by the dhtmlxError.catchError function. It looks like the XML response packet:
The code was also producing an error message, ‘invalid XML’. Upon inspecting the data in the SQL table, I discovered there were some character values in the column I was using as the identity field which caused the XML to ‘break’ and become poorly-formed. (DHMTLX carries the identitiy field value as an XML attribute, rather than placing the value in a CDATA section.)
I then used a different table column as the identity field, and the grid loaded - but I only saw 8 rows, instead of the 100 in the table which I’d expected. It turns out the new identity field only has 8 unique values, so I assume there is something similar to a SELECT DISTINCT going on.
If I have a table which has a non-unique identity field, and I want all the rows to load into the grid, what should I code for that condition, please?