Get KoolPHP UI with 30% OFF!


Glenn Byerly
I can connect to my Microsoft SQL Server database using sqlsrv_connect with associated credentials. I can then retrieve and echo out data.
I am now trying to use SQLSRVDataSource.php to connect to and display data using KoolGrid. When I do, the connection does not fail, but the returned page is totally blank.
At the end of this posting is the code I am using. The connection is identical to the one that is mentioned in the first sentence above.
	//Step 1: Register KoolGrid component to your page
	//echo "Getting required php files<br />";
	require "KoolControls/KoolGrid/koolgrid.php";
	require "KoolControls/KoolAjax/koolajax.php";
	require "KoolControls/KoolGrid/ext/datasources/SQLSRVDataSource.php"; 
	$koolajax->scriptFolder = "KoolControls/KoolAjax";
	$serverName = "(local)\SQLEXPRESS";
	// If UID and PWD are not specified in the $connectionInfo array,
	// The connection will be attempted using Windows Authentication.
	$connectionInfo = array( "Database"=>"AdventureWorksLT2014", "UID"=>"XXX", "PWD"=>"XXX");
	$conn = sqlsrv_connect( $serverName, $connectionInfo);
	if( $conn === false )  
		 echo "Unable to connect.</br>";  
		 die( print_r( sqlsrv_errors(), true));  
	$ds = new $SQLSRVDataSource($conn);
	$ds->SelectCommand = "SELECT * FROM [AdventureWorksLT2014].[SalesLT].[Customer]";
	//Step 3: Init KoolGrid and settings
	$grid = new KoolGrid("grid");
	$grid->scriptFolder = "KoolControls/KoolGrid";
	$grid->DataSource = $ds;
	$grid->AjaxEnabled = true;
	$grid->Width = "655px";
	$grid->AllowInserting = true;
	$grid->AllowSorting = true;
	$grid->AutoGenerateColumns = true;
	$grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
	//Step 4: Process Grid
        <?php echo $koolajax->Render();?>
        <form id="form1" method="post">
            <!-- Step 5: Get KoolGrid render -->
            <?php echo $grid->Render();?>
Posted Jun 23, 2019 Kool