php: odbc_connect(): SQL 错误 [英] php: odbc_connect(): SQL error
问题描述
我在连接与我的 SQL Server 在同一台 PC 上运行的 php 页面与 SQL 服务器并执行操作时遇到了大问题...
I have a big problem connecting my php page which is running on the same PC as my SQL Server with the SQL server and execute things...
也许以下警告会对您有所帮助:
Maybe this following warning will help you:
警告:odbc_connect():SQL 错误:[Microsoft][SQL Server Native Client 11.0]命名管道提供程序:无法打开到 SQL Server [53] 的连接., 第 9 行 MY_CONFIG_FILE 中的 SQLConnect 中的 SQL 状态 08001
Warning: odbc_connect(): SQL error: [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. , SQL state 08001 in SQLConnect in MY_CONFIG_FILE on line 9
我想知道是什么导致了这个问题,因为带有 php 页面的网络服务器与我的 SQL 服务器在同一台机器上运行.
I wonder what causes this problem as the webserver with the php page is running on the same machine as my SQL server does.
我正在使用此代码:
odbc_connect("Driver={SQL Server Native Client 11.0};Server='MY_IP';Database='MY_DATABASE';", 'MY_SQL_USER', 'THE_PW_OF_MY_SQL_USER');
到目前为止我尝试过的:
What I have tried so far:
- 将 IP 添加到 Windows 的主机文件中
- 关闭整个防火墙
- 添加名为 SQLEXPRESS 的用户-DSN ODBC 连接,并进行有效的连接测试
- 使用 SQL Management Studio 从我的家用 PC 连接到 SQL Server.它使用我在 SQL 配置文件中添加的相同登录数据和 IP.
- 在端口 1433 上的 SQL Management Studio 中启用 TCP/IP 和命名管道
- 多次重新启动一切(专业解决方案,我知道;))
- 在 cliconfg.exe 中启用 TCP/IP 和命名管道
我希望这里有一些大师可以帮助我:)
I hope there are some gurus here which can help me :)
提前很多次 ;)
推荐答案
很抱歉给您带来麻烦.
问题是,我使用 SQL Server Native Client 11.0
作为驱动程序.我将它切换到 SQL Server
,现在它可以工作了:/
The problem was, that I was using SQL Server Native Client 11.0
as driver.
I switched it to SQL Server
and now it works :/
希望这至少可以帮助遇到类似问题的人......
Hopefully this at least helps someone, being in a similar problem....
这篇关于php: odbc_connect(): SQL 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!