怎样用SQL 2000 生成XML

来源:互联网 发布:网络红包潮 编辑:程序博客网 时间:2024/06/11 08:59
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
以前在介绍SQL2k的时候已经提到了SQL2k对XML的支持,使用for XML语句就可以很容易的把执行的结果转化为一个XML,这样可以在很大程度上提高系统运行效率和开发速度,详细的内容请参见Books Online。

但是在使用ADO(Required ADO 2.6)访问返回的XML的方式和原来的Recordset是有所不同的。如果你还是使用Recordset访问的话,只能得到一个Unicode格式的XML Schema,而无法得到XML的内容。

其实这个问题也是很容易就能解决的,只是我自以为很熟悉ADO,没有仔细看Help,所以没有发现ADO是采用Stream的方式来得到和返回XML的。

Command 对象有两个属性,叫Input Stream和Output Stream,属性的值是一个IUnknown接口。可以把一个XML Parser的接口赋给它,或者是直接用Request、Response等。这样的好处是不需要再去生成一个Recordset,不需要去保存这些数据,从而节省了系统开销。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击