views:

270

answers:

1

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. 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

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:

From Browser:

Chinese Characters: Browser

From View Source:

Chinese Characters: View Source

However, I found that if I use a DSN connection 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. Someone told me to use an ADO.Stream object instead of a Recordset object, but I'm unsure how to implement that.

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?

A: 

You may want to check out connectionstrings.com.


edit

It looks like a database driver issue to me - which driver uses your DSN connection?

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).

Filburt
Yes. I been there, done that, tried them all that applied. Nothing has worked.
RoLYroLLs
My DSN connection uses SQL Server Native Client 10.0
RoLYroLLs
Yes, I did try both `SQLNCLI10` and `SQLNCLI10.1` early on when my first diagostics was to try every provider I see in connectionstrings.com. For sanity sake, I will try the `...10.1` again.
RoLYroLLs
Ok, the reason why `SQLNCLI10` and `SQLNCLI10.1` didn't work is because I get an error saying:`Provider cannot be found. It may not be properly installed.`Will talk to hosting company about this. and get you an update.
RoLYroLLs
well this is interesting, here's the response from my webhosting company: `In order to connect to MSSQL through an ASP script you will need to use Provider=SQLOLEDB instead of Provider=SQLNCLI10 which is incorrect on our architecture. Once those connections provider settings are updated you should be good to go.`I'm fed up with this hosting company. They have been great for the past 12 years. But now it seems like another company bought them out and I've been having issues all around!
RoLYroLLs
Actually, I tried connecting to the DB through another server which DOES have `SQLNCLI10` and `SQLNCLI10.1` installed and I am getting the same problems as mentions in the original post. I was told to try `ADO.Stream`, should I consider this? How would I implement this with my code?
RoLYroLLs
@Rolyrolls I did a little quick reading on `ADO.Stream` but couldn't see how this would save you from any driver issues. I'll see if I can dig out the samples I found ...
Filburt
@Filburt: Thanks! I actually just re-wrote the entire site to asp.net. I'd still like to know what's causing the previous issue. has happened on my shared host and my own testing environment as well as on another virtual server host.
RoLYroLLs