在SQL2000查詢中使用XDR的例子

來源:互聯網
上載者:User
XDR不會不知道吧?就是簡化的XML-Data啦。現在示範一個如何?這樣的查詢
SELECT o.OrderID, o.OrderDate from Orders o, Customers c,
WHERE o.CustomerID = c.CustomerID and c.CompanyName = ?
Code:
<%@ Language=VBScript %>
<%
Dim sConn
sConn = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=Northwind; User ID=SA;Password=;"

Dim adoConn
Set adoConn = Server.CreateObject("ADODB.Connection")
adoConn.ConnectionString = sConn
adoConn.CursorLocation = 3 'adUseClient
adoConn.Open

Dim adoCmd
Set adoCmd = CreateObject("ADODB.Command")
Set adoCmd.ActiveConnection = adoConn
adoCmd.CommandText = "Customer[@CompanyName=""Tortuga Restaurante""]"
adoCmd.Dialect = "{ec2a4293-e898-11d2-b1b7-00c04f680c56}"

adoCmd.Properties("Mapping Schema") = "Orders.xml"
adoCmd.Properties("Base Path") = "C:INETPUBWWWROOTPBA"
adoCmd.Properties("Output Stream") = Response

Response.write "<XML ID='MyDataIsle'>"
adoCmd.Execute , , 1024 'adExecuteStream
Response.write "</XML>"
%>
Result:
<XML ID="MyDataIsle">
<Customer CustomerID="TORTU" CompanyName="Tortuga Restaurante">
<Order CustomerID="TORTU" OrderID="10276" OrderDate="1996-08-08T00:00:00" />
<Order CustomerID="TORTU" OrderID="10293" OrderDate="1996-08-29T00:00:00" />
<Order CustomerID="TORTU" OrderID="10304" OrderDate="1996-09-12T00:00:00" />
<Order CustomerID="TORTU" OrderID="10319" OrderDate="1996-10-02T00:00:00" />
<Order CustomerID="TORTU" OrderID="10518" OrderDate="1997-04-25T00:00:00" />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.