没有SQl2000或者Oracle 8i怎么生成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
- 上一篇: XML 中的常见问题 (一)
- 下一篇: 从字符文档到xml文档