Access to SQL Server?
You are asking a much wider question than you might think, as this is a
multi-step process. In theory, you can do everything with the Access Upgrade
Wizard. I wish you the best of luck if you go that route, as it pretty much
sucks.
Step 1:
Query the schema of the Access database. I would ask in an Access group on
this one, as I am not sure the best way to get structure from Access. Once
you have the schema, you can set up DDL to build the schema in SQL Server.
Step 2:
Set up the database(s) in SQL Server. You can do this by issuing DDL against
the master database (create database commands) or through SQL-DMO (need to
use interop for this).
Step 3:
Set up database objects (tables, relationships, etc.). Same options as
above, but you must be connected to the user database (created above) before
issuing DDL, or your master will end up corrupt.
Step 4:
Migrate the data. This can be done by creating a DataSet from each source
and then moving the data from the Access DataSet to the SQL DataSet and
issuing an Update Command. You can also set up the data as XML and use the
XML features of SQL to put it in the database. DTS is also an option. It
cannot be programmed with C# directly, but you can use VB COM to program.
One of the easiest options is to programatically pull the Access tables to
flat files and upload using a Bulk Load process: This is not as easy on the
system, but it is quite easy to BCP or BULK_COPY data from flat files and
relatively easy to export from Access via the Access objects. This is not a
great long-term solution, but it appears you are writing a one-time process
for tons of databases, so pretty is not necessary, speed of coding is.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
*************************************************
Think outside the box!
*************************************************