LoginSignup
3
6

More than 5 years have passed since last update.

.mdb内の特定のテーブルをxmlに変換する

Last updated at Posted at 2014-06-16

Microsoft Accessを使わずに、.mdbの中から特定のテーブルをxmlとして得る。

使った環境

  • Visual Studio Express 2012 for Windows Desktop

コード(VB)

Option Explicit On

Module Module1
    Sub Main()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        'データベースに接続
        cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Users\*********\hoge.mdb", , , )
        'レコードセットを開く。保存したいテーブル名を指定
        rs.Open("テーブル名", cn)
        'レコードセットをxmlに出力
        rs.Save("C:\Users\*********\hoge.xml", ADODB.PersistFormatEnum.adPersistXML)

        MsgBox("DONE")
        rs.Close()
        rs = Nothing
        cn.Close()
        cn = Nothing

    End Sub
End Module

参照設定

  • Microsoft ActiveX Data Objects 6.0 Library
  • Microsoft ADO Ext. 6.0 for DDL and Security

その他

読み込むmdbと保存するxmlのパスは適宜。

参考

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6