设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1039|回复: 0
打印 上一主题 下一主题

[Access本身] 请帮忙,我按照示例代码试验不成功,帮我测测

[复制链接]
跳转到指定楼层
1#
发表于 2006-4-29 19:12:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
步骤1
用以下代码导出pubs.xml到c:\
Private Sub Command0_Click()
   Call Main
End Sub
Public Sub Main()
    On Error GoTo ErrorHandler

    'recordset and connection variables
    Dim rstAuthors As ADODB.Recordset
    Dim Cnxn As ADODB.Connection
    Dim strCnxn As String
    Dim strSQLAuthors As String
     
    ' Open connection
    Set Cnxn = New ADODB.Connection
    strCnxn = "rovider=sqloledb;Data Source=127.0.0.1;" & _
        "Initial Catalog=Pubs;Integrated Security=SSPI;user id=sa;password="
    Cnxn.Open strCnxn
   
    Set rstAuthors = New ADODB.Recordset
    strSQLAuthors = "SELECT au_id, au_lname, au_fname, city, phone FROM Authors"
    rstAuthors.Open strSQLAuthors, Cnxn, adOpenDynamic, adLockOptimistic, adCmdText
     
    'For sake of illustration, save the Recordset to a diskette in XML format
    rstAuthors.Save "c:\Pubs.xml", adPersistXML

    ' clean up
    rstAuthors.Close
    Cnxn.Close
    Set rstAuthors = Nothing
    Set Cnxn = Nothing
    Exit Sub
   
ErrorHandler:
    'clean up
    If Not rstAuthors Is Nothing Then
        If rstAuthors.State = adStateOpen Then rstAuthors.Close
    End If
    Set rstAuthors = Nothing
   
    If Not Cnxn Is Nothing Then
        If Cnxn.State = adStateOpen Then Cnxn.Close
    End If
    Set Cnxn = Nothing
   
    If Err <> 0 Then
        MsgBox Err.Source & "-->" & Err.Description, , "Error"
    End If
End Sub
'EndSaveVB

步骤2
请到http://www.microsoft.com/china/msdn/library/office/office/USodcac2003.mspx#EHD
找到“导入 XML 文件的结构和数据”那段示例代码,帮忙试一下,我试了,不能成功导入数据,只在当前Access2003里生成了三个表(AttributeType,data,ElementType且没有记录的)为什么?我要实现它能够成功的从pubs.xml里导入数据。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-14 11:17 , Processed in 0.090447 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表