I suggest you take the following steps:
- Create a database with a single table to hold the final results. The table should have the exact same structure as the individual files, but with a primary key field - either the path to the database file, or some other unique value for each row (this can be generated with an AutoNumber field). You may want an additional column for the database path in any case, particularly if you need to prevent rereading the same database file multiple times.
- Open an ADO.NET connection to the final database, using the OleDb provider. This entails a) creating an
OleDbConnection
object, b) creating an OleDbCommand
object that runs on the connection, c) setting the CommandText
of the command object to an SQL statement, and d) executing the command. Your SQL statement could look something like this:
INSERT INTO desttable (pkfield, field1, field2 ...)
SELECT field1, field2
FROM sourcetable
sourcetable
can also be a table in a different database like so:
INSERT INTO desttable (pkfield, field1, field2 ...)
SELECT field1, field2
FROM sourcetable IN path\to\mdb
so for each path you could build the SQL statemnt by substituting the appropriate path each time.
- If you want to iterate over all the mdb files in a particular folder, you can use the
EnumerateFiles
method of the Directory
class, in the System.IO
namespace. Alternatively, you can open up a dialog box with the OpenFileDialog
in the Windows.Forms
namespace. - Once you've figured out what kind of UI you want to see, it should be trivial to bind to this data.
No comments:
Post a Comment