没有SQl2000或者Oracle 8i怎么生成XML?

80酷酷网    80kuku.com

  oracle|sql|xml|生成xml

    当然你可以自己把Recordset编码为XML,不过挺麻烦的,效率也不高。这里介绍一种新的方法:
VB Code:
Dim objConn As New ADODB.Connection
Dim objRS As New ADODB.Recordset
Dim objStream As New ADODB.Stream


objConn.Open "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=pubs;Data Source=(local)"
objRS.Open "select * from [Employee]", objConn, adOpenForwardOnly, adLockReadOnly, adCmdText
objRS.Save objStream, adPersistXML
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
objStream.Position = 0
Debug.Print objStream.ReadText
objStream.Close
Set objStream = Nothing
-------------------
ASP Code:
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=pubs;Data Source=(local)"
objRS.Open "select * from [Employee]", objConn, adOpenForwardOnly, adLockReadOnly, adCmdText
objRS.Save Response, adPersistXML
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: