在SQL2000查询中使用XDR的例子_MySQL
程序员文章站
2022-05-30 12:06:43
...
XDR不会不知道吧?就是简化的XML-Data啦。现在示范一个如何实现这样的查询
SELECT o.OrderID, o.OrderDate from Orders o, Customers c,
WHERE o.CustomerID = c.CustomerID and c.CompanyName = ?
Code:
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:\INETPUB\WWWROOT\PBA\"
adoCmd.Properties("Output Stream") = Response
Response.write ""
adoCmd.Execute , , 1024 'adExecuteStream
Response.write " "
%>
Result:
Orders.xml
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
relation="Orders" />
SELECT o.OrderID, o.OrderDate from Orders o, Customers c,
WHERE o.CustomerID = c.CustomerID and c.CompanyName = ?
Code:
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:\INETPUB\WWWROOT\PBA\"
adoCmd.Properties("Output Stream") = Response
Response.write "
adoCmd.Execute , , 1024 'adExecuteStream
Response.write "
%>
Result:
Orders.xml
xmlns:sql="urn:schemas-microsoft-com:xml-sql">
relation="Orders" />
推荐阅读
-
mysql unique key在查询中的使用与相关问题
-
css媒体查询aspect-ratio宽高比在less中的使用
-
使用distinct在mysql中查询多条不重复记录值的解决办法
-
在Laravel5.6中使用Swoole的协程数据库查询
-
SqlServer2005中使用row_number()在一个查询中删除重复记录的方法
-
web.py在SAE中的Session问题解决方法(使用mysql存储)
-
在MySQL中自定义参数的使用详解
-
PHP使用mysql_fetch_object从查询结果中获取对象集的方法
-
在mysql中使用模糊查询时,使用中文查询结果不正确问题的解决办法
-
mysql 使用group by报错 sql_mode=only_full_group_by 在navicat中修改session 中的sql_mode