How to solve the problem that data delay cannot be synchronized during multiple AccessADO connections and cannot be updated in a timely manner

Source: Internet
Author: User
This problem has been around for a long time and has not been valued since it has not greatly affected the project progress. I have encountered this problem recently, and I am determined to study it carefully. I searched the internet for half a day, but I didn't find any easy-to-understand articles. I couldn't help it. Let's take a look at Microsoft's documents and record the Solution Process for your reference. Problem description

This problem has been around for a long time and has not been valued since it has not greatly affected the project progress. I have encountered this problem recently, and I am determined to study it carefully. I searched the internet for half a day, but I didn't find any easy-to-understand articles. I couldn't help it. Let's take a look at Microsoft's documents and record the Solution Process for your reference. Problem description

This problem has been around for a long time and has not been valued since it has not greatly affected the project progress. I have encountered this problem recently, and I am determined to study it carefully. I searched the internet for half a day, but I didn't find any easy-to-understand articles. I couldn't help it. Let's take a look at Microsoft's documents and record the Solution Process for your reference.


Problem description:

ADODB: _ ConnectionPtr m_pConnection1;

ADODB: _ ConnectionPtr m_pConnection2;

ADODB: _ RecordsetPtr m_pRecordset1;

ADODB: _ RecordsetPtr m_pRecordset2;

The initialization process is omitted ......


When using

M_pRecordset1-> Open (pSql, m_pConnection1.GetInterfacePtr (), ADODB: adOpenDynamic, ADODB: adLockOptimistic, ADODB: adCmdText );

After the INSERT, UPDATE, and Delete operations, use m_pConnection2 and m_pRecordset2 to query the updated table. We found that the data just added to m_pConnection1 could not be found and the modified data was not updated, deleting records is still in the database.

This problem occurs only when two or more connections are used for database operations. Only one connection does not. But in many cases, we have to use multiple connections to operate data at the same time, so the problem must be solved.


Solution:

Use"Transaction": Use the JRO engine to forcibly refresh the data cache of the query connection.

# Import "c: \ program files \ common files \ system \ ado \ msjro. dll "// start transaction m_pConnection-> BeginTrans (); // inster update delete operation code omitted // submit m_pConnection-> CommitTrans ();
// Refresh the cache and refresh the cache before the query, so there will be no data delay. BOOL CDBOperate: RefreshData () {JRO: IJetEnginePtr jet (_ uuidof (JRO: JetEngine); jet-> RefreshCache (m_pConnection); return TRUE ;}

Use the code above to synchronize data with multiple ACCESS connections.

References

Http://support.microsoft.com/kb/200300

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.