sqlsrv_connect:未找到数据源名称且未指定默认驱动程序 [英] sqlsrv_connect: Data source name not found and no default driver specified

查看:60
本文介绍了sqlsrv_connect:未找到数据源名称且未指定默认驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将 PHP 与远程计算机上运行的 SQL SERVER 2008 连接时遇到困难.我有 php 版本 5.4.3 和 apache 2.2.22.我的计算机上已经运行了 SQL SERVER 2008.我的 wamp\bin\php\php5.4.3\ext 文件夹中包含以下文件:

I am facing difficulties in connecting PHP with SQL SERVER 2008 running on a remote computer. I have php version 5.4.3 and apache 2.2.22. I already have SQL SERVER 2008 running on my computer. I have following files included in my wamp\bin\php\php5.4.3\ext folder:

  • php_sqlsrv_54_ts.dll
  • php_pdo_sqlsrv_54_ts.dll

关于运行简单的代码

$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn )
{
 echo "Connection established.\n";
}
else
{
 echo "Connection could not be established.\n";
 die( print_r( sqlsrv_errors(), true));
}

我收到以下错误:

Connection could not be established. Array (
    [0] => Array (
        [0] => IMSSP [SQLSTATE] => IMSSP
        [1] => -49 [code] => -49
        [2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712
    )
    [1] => Array (
        [0] => IM002 [SQLSTATE] => IM002 
        [1] => 0 [code] => 0
        [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    )
) 

但我不知道为什么要求我安装 Microsoft SQL Server 2012 Native Client.

But I dont know why I am being asked for Microsoft SQL Server 2012 Native Client installation.

php我已经尝试过这个链接,但没有成功.

phpI have tried this link but with no success.

提前致谢.

更新 1:

我下载了 php 5.3.1 并遵循了本教程和脚本就像一个魅力.

I downloaded php 5.3.1 and followed this tutorial and scripts works like a charm.

推荐答案

根据 requirements:SQLSRV 扩展要求在运行 PHP 的同一台计算机上安装 Microsoft SQL Server 2012 Native Client.

According to requirements: The SQLSRV extension requires that the Microsoft SQL Server 2012 Native Client be Installed on the same Computer that is running PHP.

这篇关于sqlsrv_connect:未找到数据源名称且未指定默认驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆