Excuse my English..

At work we have porting some app to MySQL, but there are still some Database in Access 2.0, Access 97, DBF, etc

Some important database is "codifica" is in access 2.0, this DB contain to many tables that are used in other DB.

I need copy data from Access to MYSQL
I Have the same schema in MYSQL as in Access for the tables I need to import.

I use the following code to import data from access to mysql in a simply way.
c# Code:

public void Importar()


            foreach (string tabla in tablas)


                DataTable codificaDataTable, mySqlDataTable;


                caminoCodifica = GetCaminoCodifica();

                codificaCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + caminoCodifica;

                SqlStr = "SELECT * FROM " + tabla;

                codificaAdapter = new OleDbDataAdapter(SqlStr, codificaCnn.ConnectionString);

                codificaAdapter.AcceptChangesDuringFill = false;


                codificaDataTable = new DataTable();



                if (codificaDataTable != null)


                    tabla1 = tabla + "1";

                    SqlStr1 = "SELECT * FROM " + tabla1;

                    mySqladapter = new MySqlDataAdapter(SqlStr1, mySqlcnn);

                    mySqlCmdBuilder = new MySqlCommandBuilder(mySqladapter);

                    mySqladapter.InsertCommand = mySqlCmdBuilder.GetInsertCommand();








But I need to copy not all data, but just data (Rows) present in Access that are not present in MySQL.

Any Suggestion????

Edited 3 Years Ago by Reverend Jim: Fixed formatting

How many rows are you transferring, and do you have a unique identifier for the rows? You could Select * From Table and then on the access side test if the unqiue identifier exists. If it doesn't exist then Insert Into Table () Values ()

As sknake pointed out it really depends on the amount of data you are dealing with and what platform you are comfortable with. You could pull both data sources into datasets and use LINQ or some other C# method to figure out what does or doesn't exist and insert accordingly.

If you are comfortable with SQL you could stage the data from your Access DB and use SQL scripts to compare and insert the rows that don't exist......without a unique identifier it could be difficult to do either.


This article has been dead for over six months. Start a new discussion instead.