dooid3005 2019-01-28 19:32
浏览 49

无法使Code Igniter连接到本地SQL Server Express实例

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:

enter image description here

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:

And tried almost everything but use sqlsrv driver. Again, any ideas?

The mssql driver is installed and enabled see below:

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置