【问题标题】:exporting multiple access tables to single XML将多个访问表导出到单个 XML
【发布时间】:2012-05-16 05:57:23
【问题描述】:

我有多个要导出到单个 XML 文件中的 Microsoft Access 表。如何将表的顺序和层次结构处理成我想要的 XML 结构?本质上,我希望能够反转导入 XML 过程,该过程会自动将数据分解为多个表。我可以随意使用 VBA、SQL 和任何内置导出功能。

【问题讨论】:

    标签: xml ms-access vba


    【解决方案1】:

    我使用附件在大约五分钟内生成了一个 300 万行的嵌套 xml。

    有两个关键项,

    1) 一段简单的VB,

    Public Function Export_ListingData()
    
        Dim objOtherTbls As AdditionalData
    
        On Error GoTo ErrorHandle
        Set objOtherTbls = Application.CreateAdditionalData
        objOtherTbls.Add "ro_address"
        objOtherTbls.Add "ro_buildingDetails"
        objOtherTbls.Add "ro_businessDetails"
        objOtherTbls.Add "ro_businessExtras"
        objOtherTbls.Add "ro_businessExtrasAccounts"
        objOtherTbls.Add "ro_businessExtrasAccom"
        objOtherTbls.Add "ro_businessExtrasAccom2"
    
        Application.ExportXML ObjectType:=acExportTable, _
                    DataSource:="ro_business", _
                    DataTarget:="C:\Users\Steve\Documents\Conversions\ListData.xml", _
                    AdditionalData:=objOtherTbls
    Exit_Here:
            MsgBox "Export_ListingData completed"
            Exit Function
    ErrorHandle:
            MsgBox Err.Number & ": " & Err.Description
            Resume Exit_Here
    End Function
    

    2) 使用从主键到外键的连接来链接关系管理器中的表。

    如果没有关系,代码将生成一个顺序的 xml 文件,如果有 主键之间的关系会出现 31532 错误,数据导出会失败。

    【讨论】:

      【解决方案2】:

      这是通过 VBA 的解决方案:
      http://msdn.microsoft.com/en-us/library/ff193212.aspx

      创建一个 from 并在其上放置一个按钮。右键单击按钮并选择“构建事件”并通过以下代码:

      Dim objOtherTbls As AdditionalData
      
      
      Set objOtherTbls = Application.CreateAdditionalData
      
      'Identify the tables or querys to export
      objOtherTbls.Add "internet"
      objOtherTbls.Add "mokaleme"
      
      'Here is where the export takes place
      Application.ExportXML ObjectType:=acExportTable, _
      DataSource:="internet", _
      DataTarget:="C:\myxml.xml", _
      AdditionalData:=objOtherTbls
      
      MsgBox "Export operation completed successfully."
      

      您必须在此处和引号之间输入您的表格名称:

         objOtherTbls.Add "internet"
          objOtherTbls.Add "mokaleme"
      
          DataSource:="internet"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-27
        • 1970-01-01
        相关资源
        最近更新 更多