[access database synchronization] Access database to Mysql database is updated in real time

  Project Objectives:

  The first is to transfer a large amount of data in the Access database (the original million-level data that has been saved) to the mysql database. Then, as the data in the Access increases, the mysql database must be updated synchronously, and the update cycle is customized.

  Idea: At the beginning of the transfer, I have already talked about the previous blog, which is ignored here, mainly to synchronize Access data to mysql after updating. The idea is:

  1. Use the sql statement of MAX to search the mysql data table and find the maximum time MAX (patrol_time) in the time column

  2. Select the data in the Access data table with a time greater than MAX (patrol_time), and save it to the reader with the datareader

  3. In a column-by-column manner, store the data read out with a maximum time greater than MAX (patrol_time) from the reader to the array

  4. Establish a loop, write the numbers in the array into mysql according to the corresponding

  5. Write the above logic into an infinite loop and set the time interval for loop execution

  The idea is clear. The code is directly listed below, and there is nothing difficult to understand:

  Both the logic and the code are implemented using a relatively basic and simple method. Due to the long time interval, it is not necessary to consider the performance problems of a large number of cycles, and the array is used to store and write directly.

  In fact, the slightly technical content is how to determine whether there is newly added data. In this piece, the core code is these sentences:

  as well as:

  Note that when comparing with greater than signs, the use of single and double quotes, because the time column required by the original data is of varchar type, so in the SQL statement, you must add single quotes ''

Guess you like

Origin www.cnblogs.com/sqlserver-mysql/p/12732265.html