如何将ADO导出的XML(没有持久 Recordset 文件名)导入ADO中

vrych 2003-11-26 11:15:20
我的程序如下:
Dim rs As ADODB.Recordset
Dim doc As New DOMDocument
Dim str_Conn As String
Dim str_sql As String
str_Conn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=vr"
Set rs = New ADODB.Recordset
str_sql = "select * from aa"
rs.Open str_sql, str_Conn, adOpenStatic, adLockBatchOptimistic
rs.Save doc, adPersistXML
rs.Close
在此处出错
rs.Open doc, str_Conn
MsgBox rs.Fields(1).Value
...全文
31 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
imur 2003-11-26
  • 打赏
  • 举报
回复
up
vrych 2003-11-26
  • 打赏
  • 举报
回复
可能你还不明白我的想法,我可能View层生成的DOMDocument给数据访问层处理,因为我不想去解析这个DOM,所以想知道我的DOMDocument能不能直接生成ADO
SoHo_Andy 2003-11-26
  • 打赏
  • 举报
回复
DOMDocument对象不是这样用的,ADO导出只能是具体的文件
你想用DOMDocument导入XML,就要使用Load方法

具体请看给你的网页吧

怎样在VB6。0中使用XML
http://www.yesky.com/20021016/1635180.shtml

vrych 2003-11-26
  • 打赏
  • 举报
回复
我不想保存成文件,所以我不知道DOMDocument怎样从DOMDocument中导入XML
SoHo_Andy 2003-11-26
  • 打赏
  • 举报
回复
完整一点的例子,包括导出和导入,调试通过

导出
Dim rst As Recordset
Set rst = New Recordset
rst.ActiveConnection = "PROVIDER=SQLOLEDB;DATA SOURCE=SQLServer;" & _
"Initial Catalog=pubs;Integrated Security=SSPI"
rst.CursorLocation = adUseClient
rst.Open "Select * from authors where au_lname = 'Smith'"
rst.Save App.Path & "\recordset.xml", adPersistXML
rst.Close

导入
Dim rst As Recordset
Set rst = New Recordset
rst.CursorLocation = adUseClient
rst.Open App.Path & "\recordset.xml"
rst.ActiveConnection = "PROVIDER=SQLOLEDB;DATA SOURCE=SQLServer;" & _
"Initial Catalog=pubs;Integrated Security=SSPI"

MsgBoxrst.RecordCount

save 和open 方法的第一个参数都是文件的路径名啊,你的代码是什么意思


vrych 2003-11-26
  • 打赏
  • 举报
回复
up

7,771

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧