日期:2014-05-17  浏览次数:21310 次

c#每次读取一条记录插入xml中
public void mdbToXml()
        {
            OleDbConnection mycon = null;
            
            try
            {
                string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\1.mdb;";
                mycon = new OleDbConnection(strcon);
                mycon.Open();
                //获取文件名列
                string sql = "select 文件名 from temp";
                OleDbDataAdapter ad = new OleDbDataAdapter(sql, strcon);
                DataSet ds = new DataSet();
                ad.Fill(ds,"文件名");
                string[] filesName = new string[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    filesName[i] = ds.Tables[0].Rows[i]["文件名"].ToString();
                }

                //获取单位编码列
                string sql1 = "select 单位编码 from temp";
                OleDbDataAdapter ad1 = new OleDbDataAdapter(sql1, strcon);
                DataSet ds1 = new DataSet();
                ad1.Fill(ds1);
                string[] dwbm = new string[ds1.Tables[0].Rows.Count];
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    //dwbm = new string[ds.Tables[0].Rows.Count];
                  &n