In the previous introduction of SQL2K has been mentioned SQL2K support for XML, use for XML statements can easily translate the results of execution into an XML, which can greatly improve the efficiency of the system and development speed, see what's New in Microsoft SQL Server 2000 (iv), for more details, see Books Online.
But the way the XML returned is accessed using ADO (Required ADO 2.6) is different from the original recordset. If you still use the recordset, you can only get an XML Schema in Unicode format without getting the content of the XML.
In fact, this problem is very easy to solve, but I think I am very familiar with ADO, did not look at help carefully, so did not find ADO is the way to get and return XML stream.
The Command object has two properties, called input stream and output stream, and the value of the property is an IUnknown interface. You can assign an XML parser interface to it, or use the request, response, etc. directly. The advantage is that there is no need to generate a recordset, save the data, and thus save the system overhead.
Here's a simple example to return XML with response:
<%@ Language=vbscript%>
<!--#include file= "Adovbs.inc"-->
<%
Dim objconn, objCMD, I
Set objconn = Server.CreateObject ("ADODB. CONNECTION ")
objConn.Open "Provider=SQLOLEDB.1; password=; Persist Security info=true; User id=sa;initial catalog=pba;data source= (local)
Set objcmd = Server.CreateObject ("Adodb.command")
Objcmd.activeconnection = objconn
Objcmd.properties ("Output Stream") = Response
Objcmd.properties ("XML root") = "root"
objCmd.CommandText = "SELECT * from UserStatus for XML Auto"
Response.ContentType = "Text/xml"
Objcmd.execute I, adExecuteStream
Set objcmd = Nothing
Objconn.close
Set objconn = Nothing
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.