简体   繁体   English

ASP Classic,SQL 2008,XML输出以及DSN与DSN-Less产生中文字母

[英]ASP Classic, SQL 2008, XML Output, and DSN vs DSN-Less Produces Chinese Letters

I've been having a problem for the past month and can't seem to figure out what is wrong. 在过去的一个月中,我一直遇到问题,似乎无法找出问题所在。 Here's the setup and a little background. 这是设置和一些背景知识。

Background: 背景:

I have a web-host who was running my website on Windows Server 2003 and SQL Server 2000. One of my webpages returned a result set from a stored procedure from the SQL server as xml. 我有一个网络托管商,他在Windows Server 2003和SQL Server 2000上运行我的网站。我的一个网页从SQL Server的存储过程中以xml返回了结果集。 Below is the code: 下面是代码:

Stored Procedure: 存储过程:

select top 10
    1 as tag
    , null as parent
    , column1 as [item!1!column1!element]
    , column2 as [item!1!column2!element]
from
    table1

for XML EXPLICIT

ASP Page: index.asp ASP页面:index.asp

Call OpenConn

Set cmd = Server.CreateObject("ADODB.Command")
With cmd
 .ActiveConnection = dbc
 .CommandText = "name of proc"
 .CommandType = adCmdStoredProc

 .Parameters.Append .CreateParameter("@RetVal", adInteger, adParamReturnValue, 4)
 .Parameters.Append .CreateParameter("@Level", adInteger, adParamInput, 4, Level)
End With

Set rsItems = Server.CreateObject("ADODB.Recordset")
With rsItems
 .CursorLocation = adUseClient
 .CursorType = adOpenStatic
 .LockType = adLockBatchOptimistic
 Set .Source = cmd
 .Open
 Set .ActiveConnection = Nothing
End With

If NOT rsItems.BOF AND NOT rsItems.EOF Then

 OutputXMLQueryResults rsItems,"items"

End If

Set rsItems = Nothing
Set cmd = Nothing

Call CloseConn



Sub OpenConn()
 strConn = "Provider=SQLOLEDB;Data Source=[hidden];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];"
 Set dbc = Server.CreateObject("ADODB.Connection")
 dbc.open strConn
End Sub

Sub CloseConn()
 If IsObject(dbc) Then
  If dbc.State = adStateOpen Then
   dbc.Close
  End If
  Set dbc = Nothing
 End If
End Sub

Sub OutputXMLQueryResults(RS,RootElementName)
 Response.Clear
 Response.ContentType = "text/xml"
 Response.Codepage = 65001
 Response.Charset = "utf-8"
 Response.Write ""
 Response.Write ""
 While Not RS.EOF
  Response.Write RS(0).Value
  RS.MoveNext
 WEnd
 Response.Write ""
 Response.End
End Sub

Present: 当下:

All was working great, until my host upgraded to Windows Server 2008 and SQL Server 2008. All of the sudden I was getting results like this: 一切运行良好,直到我的主机升级到Windows Server 2008和SQL Server2008。突然间,我得到了如下结果:

From Browser: 从浏览器:

Chinese Characters: Browser http://iphone.rolyrolls.com/chineseChars1.png 汉字:浏览器http://iphone.rolyrolls.com/chineseChars1.png

From View Source: 从查看源:

Chinese Characters: View Source http://iphone.rolyrolls.com/chineseChars2.png 汉字:查看源代码http://iphone.rolyrolls.com/chineseChars2.png

However, I found that if I use a DSN connection strConn = "DSN=[my DSN Name];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];" 但是,我发现如果我使用DSN连接strConn = "DSN=[my DSN Name];User Id=[hidden];Password=[hidden];Initial Catalog=[hidden];" it works perfectly fine! 它工作得很好!

My current host is not going to support DSN any longer, but that's out of scope for this issue. 我当前的主机将不再支持DSN,但这超出了此问题的范围。 Someone told me to use an ADO.Stream object instead of a Recordset object, but I'm unsure how to implement that. 有人告诉我使用ADO.Stream对象而不是Recordset对象,但是我不确定如何实现它。

Question: 题:

Has anyone run into this and found a way to fix it? 有没有人遇到这个问题并找到一种解决方法?

What about that ADO.Stream object, can someone help me with a sample that would fit my code? 那那个ADO.Stream对象呢,有人可以帮我提供适合我的代码的示例吗?

You may want to check out connectionstrings.com . 您可能需要查看connectionstrings.com


edit 编辑

It looks like a database driver issue to me - which driver uses your DSN connection? 在我看来,这是一个数据库驱动程序问题-哪个驱动程序使用您的DSN连接?

update 更新

connectionstrings.com lists the SQL Native connection with Provider=SQLNCLI10 but when I generate a .udl connection file for this provider it says Provider=SQLNCLI10.1 so this may be worth a shot (if you not already tried this). connectionstrings.com列出了与Provider=SQLNCLI10的SQL本机连接,但是当我为此提供商生成.udl连接文件时,它说是Provider=SQLNCLI10.1因此值得一试(如果您尚未尝试过)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM