[英]PHP / PDO / MSSQL how to get error informations?
I've done a lot of searching, but can't find anything about my issue. 我做了很多搜索,但找不到任何有关我的问题的信息。 I'm using
PDO
with Driver PDO_DBLIB
to access a MS SQL database. 我正在使用带有驱动程序
PDO_DBLIB
PDO
来访问MS SQL数据库。 I generally use prepared statements, but if any query fails I don't get any additional information about the error except for this: 我通常使用预准备语句,但如果任何查询失败,我不会获得有关错误的任何其他信息,除非:
General SQL Server error: Check messages from the SQL Server [241] (severity 16) [(null)]
Does anyone have a hint as to how do I retrieve more information about the error (syntax error at...)? 有没有人提示如何检索有关错误的更多信息(语法错误在......)?
best regards 最好的祝福
Michael 迈克尔
To find the error message: 要查找错误消息:
-- SQL 2005+
select * from sys.messages where message_id = 241
-- SQL 2000
select * from sysmessages where error = 241
It appears that PDO is removing the actual error message text for some reason, but since the documentation says that PDO_DBLIB is experimental, this may simply be a bug. 由于某种原因,PDO似乎正在删除实际的错误消息文本,但由于文档说PDO_DBLIB是实验性的,这可能只是一个错误。
You should also be aware that DBLIB has been deprecated by Microsoft since SQL 2005, so you should almost certainly use a different library for connecting to MSSQL. 您还应该知道,自SQL 2005以来,Microsoft已弃用 DBLIB,因此您几乎肯定会使用不同的库来连接到MSSQL。
SQL Server Error Messages SQL Server错误消息
error 241: Syntax error converting datetime from character string
错误241:从字符串转换datetime的语法错误
This format works for me: date("Ymd H:i:s");
这种格式适用于我:
date("Ymd H:i:s");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.