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; }
public static DataTable ExecuteDataTable(string commandText, params object[] paras) { DataSet ds = OleDbHelper.ExecuteDataSet(connString, commandText, paras); return(ds.Tables[0]); }
//get // { // //Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); // string connStr = ConfigurationManager.ConnectionStrings["Xiucai.DbConnection"].ConnectionString; //bool useEncrypt = ConfigHelper.GetValue("useEncrypt").ToLower() == "true"; // if (useEncrypt) // return StringHelper.UnBase64(connStr); // else // return connStr; // } public static DataTable ExecuteDataTable(string commandText) { DataSet ds = OleDbHelper.ExecuteDataSet(connString, commandText, null); return(ds.Tables[0]); }