Hi, I’m a newbie. I try to connect with mssql but failed. Would it be possible someone advise me as my code below.
This is the connection string
‘db’=>array(
'connectionString' => 'sqlsrv:server=dvlserver1;database=Northwind;',
'username' => 'sa',
'password' => 'nomsod999$$',
'charset' => 'utf8',
),
This is at Controller
$sql = "SELECT * FROM customers";
$dataProvider = new CSqlDataProvider($sql,array(
'pagination' => array(
'pageSize' => 10,
),
));
$this->render('index', array('dataProvider' => $dataProvider));
This is code at View
$this->widget(‘zii.widgets.grid.CGridView’,array(
'id' => 'grid1',
'enablePagination' => TRUE,
'columns' => array(
array(
'name' => 'customerID',
'header' => 'CustomerID',
),
array(
'name' => 'CompanyName',
'header' => 'Company',
),
array(
'name' => 'contractName',
'header' => 'Contract',
),
),
));
This is the Error I have got
[b]The "dataProvider" property cannot be empty.
C:\AppServ\www\MyYii\framework\zii\widgets\CBaseListView.php(103)[/b]
I do apologize first, that I place a lot of code here…
Foon.