简体   繁体   中英

How to synchronise Access database with SQL Server,changes made in access database should reflect in SQL server database

How to synchronise Access database with SQL Server , so that changes made in access database should reflect in SQL server database. Provided that the front end is Vb6.

There is no easy way. You have to:

  1. add checksum colon in every table
  2. calculate checksum in Access table for new & changed records
  3. update changed records (existing key, different checksum)
  4. add new records (non-existing keys)

at 1. VB6 doesn't have any checksum function. At internet are tons of VB6 checksum functions, find one and implement. Data type with more bytes is better. Hint: join all values in record in a string (something like CSV) and calculate checksum for this string.

at 2. The correct way is calculate checksum in change/new record event in your application. Less correct, but possible, is calculate checksum just before synchronisation (it depends on quantity of records and so on).

Note: Great checksum function in SQL Server is fn_repl_hash_binary. The result you can convert in uniqueidentifier type ( number / Replication ID in Access). In this case you should calculate checksum by SQL server via Linked server just before synchronisation.

 SELECT CONVERT(uniqueidentifier, master.sys.fn_repl_hash_binary(@whatever))

at 3. and 4. There are some ways, how to use mdb from SQL Server. Choose the best for you.

  • Linked servers (Note you need an extra permission, see sp_configure 'Ad Hoc Distributed Queries', 1 )
  • OPENROWSET and OPENDATASOURCE
  • and, off course, process record by record in your VB6 application. Horrible way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM