Jamers Posted January 4, 2017 Report Share Posted January 4, 2017 刚好有windows下连接sql server的需求,使用CI3.1.2框架进行连接,发现不管怎么样都无法连接,实在没办法,用底层函数连接试一下吧。 <?php $serverName = "127.0.0.1"; $connectionInfo = array( "Database"=>"gurms", "UID"=>"gurms", "PWD"=>"gurms"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); } ?> 得到的结果是: Connection could not be established.Array( [0] => Array ( [0] => IMSSP [sqlSTATE] => IMSSP [1] => -49 => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [sqlSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序 [message] => [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序 )) 根据这个错误提示,去微软下载ODBC驱动,要对应自己的版本,X64 or X86,安装后运行脚本一切正常,使用CI进行测试,PASS。 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now