Welcome Guest, Not a member yet? Register   Sign In
'Invalid DB driver' error when connecting CodeIgniter framework to Sql Server
#1

This is the error:
 
Quote:An Error Was Encountered.
Invalid DB driver

  
I am using CodeIgniter 3.1.9 framework for a website and I am on the process of connecting the database I imported on HeidiSQL to the framework.
 
To connect to the database, I decided to install sql server drivers for the specific php version I have (PHP 7.2.9). By the way, I have Microsoft SQL Server 2012 Native Client installed and my operative system is a Windows 7 Professional 64 bits.
 
I created a folder inside CodeIgniter named 'sqlsrv' and installed the drivers inside.
 
I configured php.ini file like this, adding the extensions needed:
 

Code:
    extension=sqlsrv
    extension=php_sqlsrv.dll
    extension=php_sqlsrv_72_ts_x64.dll
    extension=php_sqlsrv_72_ts_x86.dll
    extension=php_pdo_sqlsrv_72_ts_x64.dll
    extension=php_pdo_sqlsrv_72_ts_x86.dll
    extension=php_pdo.dll

 
 
 
And here is the database.php configuration file (server/hostname, port, username, database/dbname and password values are not real for safety):
 
   
Code:
$active_group = 'default';
    $query_builder = TRUE;
    $db['default'] = array(
                'dsn'      => 'Driver={SQL Server 2012 Native Client};server=192.168.7.88;port=1422;dbname=database_name;username=user_name;password=pass',
                'hostname' => '192.168.7.88',
                'username' => 'user_name',
                'password' => 'pass',
                'database' => 'database_name',
                'dbdriver' => 'sqlsrv',
                'dbprefix' => '',
                'pconnect' => FALSE,
                'db_debug' => TRUE ,
                'cache_on' => FALSE,
                'cachedir' => '',
                'char_set' => 'utf8',
                'dbcollat' => 'utf8_general_ci',
                'swap_pre' => '',
                'autoinit' => TRUE,
                'encrypt' => FALSE,
                'compress' => FALSE,
                'stricton' => FALSE,
                'failover' => array(),
                'save_queries' => TRUE
               
    );



I tried changing the content inside 'dsn' value, enabling more sql server drivers and infinite other ways like using odb (not useful because query builder is not allowed) alternatively and it's still not working.

How can I solve this? 

And is a good practice to choose sql server driver for the specs I mentioned?
Reply
#2

First do you use mssql express?
I use Codeigniter with sqlserver express 2014 and 2012 with iis 7 with no problems.
This is my database config:

Code:
$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'    => '',
    'hostname' => 'Your servname\SQLEXPRESS', // for example 'cmms-server\SQLEXPRESS'
    'port' => '1433',
    'username' => 'your username',
    'password' => 'your password',
    'database' => 'your tablename',
    'dbdriver' => 'sqlsrv',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

);
 
Look also if the drivers are loaded in de PHP.ini .
Good luck
Andre
Reply




Theme © iAndrew 2016 - Forum software by © MyBB