Yii Framework Forum: Sqlsrv Connection Fails To Open - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sqlsrv Connection Fails To Open CDbConnection failed to open the DB connection: SQLSTATE[IMSSP] Rate Topic: -----

#1 User is offline   Neil Kenealy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 31-October 11

Posted 21 June 2013 - 03:57 PM

I'm running yii on my local machine on WAMP. I also have a database which is installed with MS SQL Server 2008 R2
Normally I run yii with a mysql database but now I'm trying to set up yii on MS SQL server

config =
'db'=>array(
'connectionString' => 'sqlsrv:server=localhost;database=NEIL',
// 'emulatePrepare' => true,
'username' => 'xxxxx',
'password' => 'xxxx',

When I run ?=gii to create model, controller and CRUD code I'm getting the following error message at this code:

public function init()
56 {
57 if(Yii::app()->{$this->connectionId}===null)
58 throw new CHttpException(500,'A valid database connection is required to run this generator.');
59 $this->tablePrefix=Yii::app()->{$this->connectionId}->tablePrefix;
60 parent::init();
61 }

This is the error message:
CDbConnection failed to open the DB connection: SQLSTATE[IMSSP]: This extension requires the Microsoft SQL Server 2012 Native Client ODBC Driver to communicate with SQL Server. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft..../?LinkId=163712

I have downloaded an installed these sqlsrv drivers.

extension=php_pdo_sqlsrv_53_ts.dll

This is what my phpinfo says:

pdo_sqlsrv

pdo_sqlsrv support enabled

Directive Local Value Master Value
pdo_sqlsrv.client_buffer_max_kb_size 10240 10240
pdo_sqlsrv.log_severity 0 0

I have also installed the Microsoft ODBC Driver 11 for SQL Server.
However I didn't configure this ODBC driver in any way. I only installed.
Do I need to do some configuration of the driver?

Thank you in advance for your help.

Neil
0

#2 User is offline   Neil Kenealy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 31-October 11

Posted 22 June 2013 - 12:35 AM

I have now onnfigured and tested the ODBC driver.
However, I am still getting the same error.
0

#3 User is offline   Neil Kenealy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 31-October 11

Posted 22 June 2013 - 06:04 AM

Hi

I solved the problem. I now have a connection to the SQL Server Database.

I used this link as a guide http://vimalakanchan...p-using-sqlsrv/

installed these extensions
extension=php_sqlsrv_53_ts_vc9.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll


this is PHPinfo
sqlsrv
sqlsrv support enabled

Directive Local Value Master Value
sqlsrv.LogSeverity 0 0
sqlsrv.LogSubsystems 0 0
sqlsrv.WarningsReturnAsErrors On On

'connectionString' => 'sqlsrv:server=servername ; Database=databasename',
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users