void IFileConverter.Export(System.Data.DataSet ds, string filename) { string connectionString = ConnectionStringManager.MakeAccess(filename, Options.Username, Options.Password, false); #region Create DB if not already exist if (!File.Exists(filename)) { using (ADOX_CatalogClass adox = new ADOX_CatalogClass()) { // http://support.microsoft.com/kb/317881 adox.CatalogClass.Create(connectionString); } if (!File.Exists(filename)) { throw new FileNotFoundException("unable to create file: " + filename); } } #endregion DataFactory df = new DataFactory(DatabaseProvider.OleDb, connectionString); df.TestConnection(); foreach (DataTable dt in ds.Tables) { df.CreateTable(dt.TableName, dt); } }
private void UpdateTableList() { switch (InputDataSource) { case InputDataSourceType.File: if (FileSupportsTables(Filename)) { switch (GetFileExtension(Filename)) { case "MDB": Provider = DatabaseProvider.OleDb; ConnectionString = ConnectionStringManager.MakeAccess(Filename, null, null, true); break; case "XLS": Provider = DatabaseProvider.OleDb; ConnectionString = ConnectionStringManager.MakeExcel(Filename, null, null, true, true); break; case "XLSX": Provider = DatabaseProvider.OleDb; ConnectionString = ConnectionStringManager.MakeExcel2007(Filename, null, null, true, true); break; default: throw new ArgumentException("File extension not supported: " + Filename); } GetTableListing(Provider, ConnectionString); } break; case InputDataSourceType.Database: GetTableListing(Provider, ConnectionString); break; default: throw new ArgumentOutOfRangeException("InputDataSource=" + InputDataSource); } }
System.Data.DataSet IFileConverter.Import(string filename) { string connectionString = ConnectionStringManager.MakeAccess(filename, Options.Username, Options.Password, false); return(Common.OleDbTables(connectionString, Options.Tablename, Options.TableFilter)); }