我想创建一个用xml文件中的数据填充的访问数据库 [英] I want to create an access database populated with data from xml file

查看:70
本文介绍了我想创建一个用xml文件中的数据填充的访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个xml文件创建一个Access数据库('mdb').

I want to create an Access database('mdb') from an xml file.

创建空访问数据库很容易(我能够做到),在弄清楚如何创建表并使用代码动态地从xml文件中填充数据时遇到了问题.

Creating empty access database is easy(I am able to do this), I am having problem in figuring out how can we create a table and populate it with data from the xml file on the fly through code.

我正在使用C#.

推荐答案

您可以将XML文件读入数据集,然后将其填充到数据库中.

You can read the XML file into a DataSet, then populate it into your database.

DataSet ds = new DataSet();
ds.ReadXml(filename);

foreach(DataTable table in ds.Tables) {

    //Create table

    foreach(DataRow row in table.Rows) {
        //Insert rows
    }
}

这篇关于我想创建一个用xml文件中的数据填充的访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆