简体   繁体   English

如何将Access数据库与SQL Server同步,在Access数据库中所做的更改应反映在SQL Server数据库中

[英]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. 如何将Access数据库与SQL Server同步,以便对Access数据库所做的更改应反映在SQL Server数据库中。 Provided that the front end is Vb6. 前提是前端为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. 在1。VB6没有任何校验和功能。 At internet are tons of VB6 checksum functions, find one and implement. 互联网上有大量的VB6校验和功能,找到一个并实现。 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. 提示:将记录中的所有值连接到一个字符串中(类似于CSV),并计算该字符串的校验和。

at 2. The correct way is calculate checksum in change/new record event in your application. 在2。正确的方法是在应用程序的更改/新记录事件中计算校验和。 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. 注意:SQL Server中很棒的校验和功能是fn_repl_hash_binary。 The result you can convert in uniqueidentifier type ( number / Replication ID in Access). 您可以转换为uniqueidentifier类型的结果(Access中的数字/复制ID )。 In this case you should calculate checksum by SQL server via Linked server just before synchronisation. 在这种情况下,您应该在同步之前通过链接服务器通过SQL服务器计算校验和。

 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. 在3.和4。有一些方法,如何使用SQL Server中的mdb。 Choose the best for you. 选择最适合你的。

  • Linked servers (Note you need an extra permission, see sp_configure 'Ad Hoc Distributed Queries', 1 ) 链接的服务器 (请注意,您需要额外的权限,请参见sp_configure'Ad Hoc Distributed Queries',1
  • OPENROWSET and OPENDATASOURCE OPENROWSETOPENDATASOURCE
  • and, off course, process record by record in your VB6 application. 当然,还可以在VB6应用程序中逐条记录地处理记录。 Horrible way. 可怕的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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