问题标签 [sqlsrv]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
760 浏览

php - PHP's SQLSRV driver would not complete a Stored Procedure query that works normally elsewhere

So I'm confident that the stored procedure works, I've tested it in SQL Server Management Studio just fine and it runs in other service instances. The query used to run this SP follows;

So it runs fine on SSMS and under the old MSSQL driver. But I run the query with SQLSRV like so;

The function is named mssql_query because we're updating an old system from MSSQL to SQLSRV, but we're working with an extremely messy old system. So rather than trying to refactor it we're overwriting the MSSQL_query function (having disabled the mssql extension) with one that uses SQLSRV. $dbhandle is our SQLSRV connection resource. Other queries run just fine using this method.

So my question- is there any reason the query to run a stored procedure would not run under this SQLSRV function?

Couple notes on my troubleshooting;

I'm aware SQLSRV and PDO have a specific method to run stored procedures. Using that is not an option due to the massive codebase that uses the method above in various places and because we haven't got the man hours to refactor every page.

I pulled up SQLSRV_errors() and it returned 'Executing SQL directly; no cursor'. After a bit of research this seems to be a bug in the driver that returns this generic error message instead of a more specific useful one, so it can mean very many things. There are no cursors or loops involved in the stored procedure.

0 投票
2 回答
7743 浏览

php - 查询的活动结果不包含任何字段

我收到以下错误:The active result for the query contains no fields

下面是我的代码

我得到的确切错误:

这是我从其他论坛找到的解决问题的一个建议:使用sqlsrv_next_result. 我用过它,它说 ODBC 函数序列错误(类似的东西)。

当我将我的 sql 语句更改为这样说时,还有一些需要注意的地方:

它实际上可以工作并显示消息。有点奇怪。

谁能解释这个错误信息?

0 投票
1 回答
2544 浏览

php - SQLSRV 查询不起作用

我只是使用 IIS 和 Microsoft SQL 服务器设置了一个 PHP 服务器,它们都运行在同一台 Windows Server 2008 机器上。我在 PHP 上安装了 Microsoft 的 SQLSRV 驱动程序,因为我想在 PHP 中使用我的 SQL Server 数据库。

连接到 SQL Server 实例在代码中运行良好,但是当我尝试执行查询时,它不再起作用。我尝试从 php 代码运行的相同查询正在其他程序中运行,例如我的 SQL Server 管理器。即使是像“USE dbname”这样的简单命令也无法正常工作,但它们可以在 SQL Server 管理器中工作。

这是我正在使用的 PHP 代码。当我运行代码时,它显示已连接,然后出现错误选择数据库。

当我运行 sql_srverrors() 而不是打印 'error selection DB' 时,它只给了我 'Array' 这个词,仅此而已,没有错误消息,什么都没有。

0 投票
1 回答
61 浏览

php - 检索存储过程

下面我尝试使用以下四个参数调用存储过程。但是,我没有收到任何错误,结果也没有产生任何记录。我在填充 1 条记录的数据库中运行查询。有任何想法吗?

我继续尝试制作唱片,我能够呼应出来

但是,while 循环不会产生记录。

问候乔什

0 投票
1 回答
8476 浏览

php - SQLSRV 3.0 安装 - 未定义函数 sqlsrv_connect() IIS、php5.4.3、

我已经阅读(并尝试过)我能找到的每一篇文章,但没有运气。phpinfo 不显示 sqlsrv,但 ext 文件夹是正确的(经过测试)并且 dll 在那里。

它们在 c:/PHP/ext 中
使用 FastCGI,确实重新启动了 IIS 以及整个服务器。
这个版本的 PHP (X86) 和 MSSQL10_50.SQLEXPRESS 已经安装并工作了一年。

Windows Server 2008 R2
PHPINFO
编译器:MSVC9 (Visual C++ 2008)
PHP 扩展构建:API20100525,NTS,VC9

但是,在 PHPINFO 上,我在配置命令中看到了这一点:

刚刚找到并添加:

然后:

所以我知道我已经正确安装了 dll

任何帮助将不胜感激 - 到目前为止两天!

0 投票
1 回答
517 浏览

php - 使用 TSQL 和 PHP 从存储过程返回值

是否可以使用连接到 Windows 服务器数据库的 SQLSRV 从 PHP 中的存储过程返回数据。目前,我的代码成功提交了查询,但没有返回任何内容。行输出甚至不运行一次的循环(即对象为空)

这是PHP

这是存储过程

请注意:如果我复制并粘贴 php ($sql1) 中使用的确切 sql,它会在 SQL Server Management Studio 中正确返回一行。我认为我正在尝试可以完成,这是正确的方法吗?

谢谢。

0 投票
3 回答
964 浏览

php - 在 Windows 2003 服务器上连接到 mssql server 2008 时出现 sqlsrv 错误

在使用 PHP 的 windows 2003 服务器上使用 sqlsrv 连接 mssql server 2008 时出现以下错误sqlsrv_connect。已安装 Microsoft SQL Server 2008 Native Client。在 IIS 6.0 上运行的 Web 服务器

这是 php.ini 的内容

========================

========================

0 投票
1 回答
401 浏览

php - 推进 - 多连接性能

我是基于两个独立数据库的 php 项目。一个是 MySQL DB,另一个是 Microsoft SQL-server。基本上我已经配置了整个环境,它几乎可以正常工作。

几乎,因为我在尝试访问两个数据库时注意到一些糟糕的性能。

我的由 propel 生成的 DB Config 如下所示:

我检查了 propel.log,但我注意到那里只记录了来自 db1 的查询。所以我使用我自己的文本文件日志类来记录响应时间。每当我尝试从 db2 获取数据时,响应时间都在 1s 左右,这是不可接受的。

之后我尝试单独处理 db2 并且相同的查询花费了大约 0.07 秒!所以我认为推进在切换连接时会导致延迟。

我进行了第二次测试——我在推进配置中将 db2 设置为默认值。当我这样做时,来自 db2 的查询执行得更快(再次 - 相同的查询 0.07 秒)。

这是正常行为吗?处理多个数据库是否总是会导致性能问题?

无论如何让它更快?

提前感谢您的帮助。如果需要,我很乐意提供一些额外的细节。

0 投票
1 回答
1853 浏览

php - PHP Sqlsrv 分页

我在进行查询时遇到问题,它返回大约 30 页,我希望它返回 1,2,3...,30 而不是 1,2,3,4, 5、6、7、8等 请参阅下面的代码,了解我使用过的代码:

0 投票
1 回答
2190 浏览

php - php - sql server:“set identity_insert on”不起作用

我目前正在使用 sql server 数据库开发 php 应用程序。我在 php 中使用 sqlsrv 驱动程序对我的数据库进行查询。

问题是我必须在具有身份规范的字段上进行插入。我尝试使用指令“SET IDENTITY_INSERT tableName ON”,但看起来它不适用于 sqlsrv_query ...

有谁知道如何解决这个问题?

提前致谢。