Unix Technical Forum

XML Problem in SQL Server 2000

This is a discussion on XML Problem in SQL Server 2000 within the SQL Server forums, part of the Microsoft SQL Server category; --> We are having a problem with XML in SQL Server 2000. When we run a stored procedure that uses ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 07:26 AM
Beetle
 
Posts: n/a
Default XML Problem in SQL Server 2000

We are having a problem with XML in SQL Server 2000.
When we run a stored procedure that uses FOR XML Explicit from the
Query Analyzer, it returns the correct format :
<HIT_SUMMARY><rank>1</rank><hits>1</hits><object_type_id>2</object_type_id><object_id>19</object_id><object_title>About
Us</object_title><object_type_description>Node</object_type_description>...
etc

But when we try and execute this from asp or VB it returns the
incorrect syntax:
?rank?hits?object_type_id?object_id?object_title?o bject_type_description?content_object_type_id?cont ent_object_id?content_object_type_description?site _id?target_audience_name?target_audience_id?PageCo unt?CurrentPage?PageSize?......etc

It used to work perfectly...is this something to do with collation or
service packs?

Thanks in advance!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 07:26 AM
Simon Hayes
 
Posts: n/a
Default Re: XML Problem in SQL Server 2000


"Beetle" <ed_hall_london@yahoo.co.uk> wrote in message
news:1115822354.460148.230250@z14g2000cwz.googlegr oups.com...
> We are having a problem with XML in SQL Server 2000.
> When we run a stored procedure that uses FOR XML Explicit from the
> Query Analyzer, it returns the correct format :
> <HIT_SUMMARY><rank>1</rank><hits>1</hits><object_type_id>2</object_type_id><object_id>19</object_id><object_title>About
> Us</object_title><object_type_description>Node</object_type_description>...
> etc
>
> But when we try and execute this from asp or VB it returns the
> incorrect syntax:
> ?rank?hits?object_type_id?object_id?object_title?o bject_type_description?content_object_type_id?cont ent_object_id?content_object_type_description?site _id?target_audience_name?target_audience_id?PageCo unt?CurrentPage?PageSize?......etc
>
> It used to work perfectly...is this something to do with collation or
> service packs?
>
> Thanks in advance!
>


I have no idea myself, but you might try posting in
microsoft.public.sqlserver.xml.

Simon


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 07:27 AM
Erland Sommarskog
 
Posts: n/a
Default Re: XML Problem in SQL Server 2000

Beetle (ed_hall_london@yahoo.co.uk) writes:
> We are having a problem with XML in SQL Server 2000.
> When we run a stored procedure that uses FOR XML Explicit from the
> Query Analyzer, it returns the correct format :
><HIT_SUMMARY><rank>1</rank><hits>1</hits><object_type_id>2</object_type_id>

<object_id>19</object_id><object_title>About
>

Us</object_title><object_type_description>Node</object_type_description>...
> etc
>
> But when we try and execute this from asp or VB it returns the
> incorrect syntax:
>

?rank?hits?object_type_id?object_id?object_title?o bject_type_description?con
tent_object_type_id?content_object_id?content_obje ct_type_description?site_i
d?target_audience_name?target_audience_id?PageCoun t?CurrentPage?PageSize?...
....etc
>
> It used to work perfectly...is this something to do with collation or
> service packs?


If you are using the SQLOLEDB provider, you cannot receive FOR XML as a
recordset. Well, you can, but you get a binary blob instead. The recommended
way is to get it through a stream instead.

If you use the MSDASQL proivder, that is OLE DB over ODBC, you get the XML
as expected. However, usage of MSDASQL with SQLOLEDB is deprecated.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 07:36 AM
Beetle
 
Posts: n/a
Default Re: XML Problem in SQL Server 2000

Hi there

Thanks for the responses.
We managed to "work around" this problem by using the .dialect property
of the command object.
Here is the code we used:

================================================== =============
Dim oCmd, sSQL
Dim str1
sSQL = "<root><sql:query
xmlns:sql='urn:schemas-microsoft-com:xml-sql'>" & _
"xmlfetch_emp</sql:query></root>"

Set oCmd = Server.CreateObject("ADODB.Command")
oCmd.ActiveConnection =
"Provider=SQLOLEDB;Server=basundi;Database=sutton; UID=sa;PWD=sa;"

oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"

''' This assumes you're using IIS 5
''' In IIS4 the Response object doesn't implement the IStream
''' interface.

' Create the output stream to stream the results into.
Set outStrm = CreateObject("ADODB.Stream")
outStrm.Open

oCmd.Properties("Output Stream") = outStrm
oCmd.Execute , , 1024
outStrm.Position = 0
' Create temporary string.
Dim str
' Assign the stream's output to the temp string to format.
str = outStrm.ReadText(-1)

Response.Write Server.HTMLEncode(str)

Set oCmd = Nothing

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

Hope you find this useful
Cheers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 07:36 AM
Erland Sommarskog
 
Posts: n/a
Default Re: XML Problem in SQL Server 2000

Beetle (ed_hall_london@yahoo.co.uk) writes:
> Thanks for the responses.
> We managed to "work around" this problem by using the .dialect property
> of the command object.


Ah, interesting! Thanks for posting your findings!


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:55 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com