针对 SQL Server 2008 从 ADO 访问 XML 流
我们正在迁移使用 ADO 连接到 SQL Server 2000 的 ASP 代码。在定义连接后,大部分代码都顺利迁移到 SQL Server 2008,但其中一种类型的查询会引发令我困惑的错误。
针对 SQL 2000,我们将使用如下代码:
set oCommand = Server.CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConn 'already established
oCommand.CommandType = adCmdText
'This is simplified over the real code, but the wrapper is what we use.
oCommand.CommandText = "<Root xmlns:sql='urn:schemas-microsoft-com:xml-sql'><sql:query>"
+ Server.HTMLEncode(sql)
+ "</sql:query></Root>"
oCommand.Dialect = "{5D531CB2-E6ED-11D2-B252-00C04F681B71}" 'SQL Dialect GUID
oCommand.Properties("Output Stream").Value = oXMLDoc 'Already created
oCommand.Execute , , adExecuteStream 'The point of error
SQL 是一个存储过程调用,正常调用时可以工作。 此代码继续针对 SQL 2000 工作,但针对 SQL 2008 它返回:
ERR_OPENSQLXML XMLDB.openSQLXML 失败。 错误“-2147217898”:“此提供程序不支持命令方言。”
我的第一个猜测是 SQL 2008 依赖于 MSXML 版本 6,我需要一个新的 guid。 我的 MSDN 和 Google-Fu 让我失望了:我找到的所有结果都使用这个 GUID。
有新的 GUID 吗? 有没有更好的办法? 这是比在 ASP.NET 中重新编码更省事的方法吗(许多页面的命运已经如此)。
编辑:我想知道使用 SQLNCLI10 客户端是否会阻止此工作?
configConnString =
"Provider=SQLNCLI10;DataTypeCompatibility=80;Server=XYZZY;Database=ucpm;MARS Connection=True;Trusted_Connection=Yes;"
We are migrating ASP code that used ADO to connect to SQL Server 2000. For the most part the code migrated without a hitch to SQL Server 2008 after defining the connection, but one type of query is throwing an error that puzzles me.
Against SQL 2000, we would use code like this:
set oCommand = Server.CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConn 'already established
oCommand.CommandType = adCmdText
'This is simplified over the real code, but the wrapper is what we use.
oCommand.CommandText = "<Root xmlns:sql='urn:schemas-microsoft-com:xml-sql'><sql:query>"
+ Server.HTMLEncode(sql)
+ "</sql:query></Root>"
oCommand.Dialect = "{5D531CB2-E6ED-11D2-B252-00C04F681B71}" 'SQL Dialect GUID
oCommand.Properties("Output Stream").Value = oXMLDoc 'Already created
oCommand.Execute , , adExecuteStream 'The point of error
The SQL is a stored procedure call that works when called normally. This code continues to work against SQL 2000, but against SQL 2008 it returns:
ERR_OPENSQLXML XMLDB.openSQLXML failed. Error '-2147217898': 'Command dialect is not supported by this provider.'
My first guess is that SQL 2008 relies on MSXML version 6, and I need a new guid. My MSDN and Google-Fu has failed me: all the results I find use this GUID.
Is there a new GUID? Is there a better way? Is that better way less hassle than recoding in ASP.NET (the fate of many pages already).
EDIT: I'm wondering if using the SQLNCLI10 client is preventing this from working?
configConnString =
"Provider=SQLNCLI10;DataTypeCompatibility=80;Server=XYZZY;Database=ucpm;MARS Connection=True;Trusted_Connection=Yes;"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
而不是专注于我没有看到记录为已更改的语言 - ASP.dll 在 Windows Server 的下一个版本中仍然受我上次检查的支持。
您能否检查您连接的客户端是否安装了 MSSQL Native Client 10,而不是旧的 sql 2000 odbc/oledb 客户端。
Rather than focus on the language which i haven't seen documented as changed - ASP.dll is still supported in the next version of windows server from the last check i made.
Can you check the client you are connecting from has the MSSQL Native Client 10 installed rather than the old sql 2000 odbc/oledb clients.