Exemple #1
0
        private void btnCSV_Click(object sender, EventArgs e)
        {
            string      access = @"DB\WinFramework.mdb";
            OleDbHelper helper = new OleDbHelper(access);
            string      sql    = string.Format("Select * from mps_MailDetail ");
            DataTable   dt     = helper.ExecuteDataSet(sql).Tables[0];

            //导出到CSV文件
            string fileName = Path.Combine(Application.StartupPath, "mps_MailDetail.csv");

            CSVHelper.DataTableToCSV(dt, fileName);

            //从CSV文件导入到DataTable
            DataTable dtNew = CSVHelper.CSVToDataTableByOledb(fileName);

            this.dataGridView1.DataSource = dtNew.DefaultView;
        }