I have been struggling for the last three hours with the following issue and so far I can't get this to work properly.
I have an SQL Express instance running in my PC, I have checked already the port 1433
is listening by running netstat -an
:
I am able to connect through telnet
by using the following command:
telnet SQLEXPRESS 1433
This is how my database.php
file looks like:
$active_group = 'mssql_common';
$db['mssql_common']['hostname'] = 'SQLEXPRESS';
$db['mssql_common']['username'] = 'ssEPA_User';
$db['mssql_common']['password'] = '**********';
$db['mssql_common']['database'] = 'ssEPA_DEV';
$db['mssql_common']['dbdriver'] = 'mssql';
$db['mssql_common']['dbprefix'] = '';
$db['mssql_common']['pconnect'] = false;
$db['mssql_common']['db_debug'] = true;
$db['mssql_common']['cache_on'] = false;
$db['mssql_common']['cachedir'] = '';
$db['mssql_common']['char_set'] = 'utf8';
$db['mssql_common']['dbcollat'] = 'utf8_general_ci';
$db['mssql_common']['swap_pre'] = '';
$db['mssql_common']['autoinit'] = true;
$db['mssql_common']['stricton'] = false;
$db['mssql_common']['port'] = 1433;
But for some reason, unknown to me, I keep getting the following error:
Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346
For the hostname
setting I have tried all this combinations (one at a time):
$db['mssql_common']['hostname'] = 'SQLEXPRESS'; // instance name
$db['mssql_common']['hostname'] = 'ARX1607\SQLEXPRESS'; // pc_name\instance name
$db['mssql_common']['hostname'] = 'localhost';
$db['mssql_common']['hostname'] = '127.0.0.1';
$db['mssql_common']['hostname'] = '192.168.56.1'; // DHCP address
None of the above worked. This is driving me crazy!!!
Note: I am using Code Igniter 2.3.1 (legacy application and I can't upgrade) and PHP 5.3.3 (do not ask me why :p lol) The app is running inside a VirtualBox box using Vagrant so PHP, Apache are on the server side (guest), SQLServer is on Windows side (host).
Does any have any ideas?
I have checked a few posts here like:
- How to connect code igniter 3.1.8 with sql server 2000
- CodeIgniter MSSQL connection
- Codeigniter: How to setup connection to a SQL server (2008)
- CodeIgniter MSSQL connection
And tried almost everything but use sqlsrv
driver. Again, any ideas?
The mssql
driver is installed and enabled see below: