Solved

Delayed write to an Access db.

Posted on 2011-03-11
1
235 Views
Last Modified: 2012-05-11
Hi Experts,

I am writing data to an Access data base and then retrieving  that data immediately. I am finding that sometimes the data is not being written quickly to the db. How can I ensure that data is written to the db before the program continues execution. I have tried closing the db connection before attempting to retrieve the info. but this does not seem to help.
0
Comment
Question by:DColin
1 Comment
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35110078
Hi,

Try to use transacction on when you insert/update/delete the data in Access, something like this


Dim conConnection As New OleDbConnection
        conConnection.ConnectionString = "YOURSTRINGCONNECTION"
        conConnection.Open()

        Dim comCommand As New OleDbCommand
        Dim trnTranasction As OleDbTransaction

        comCommand.Connection = conConnection
        trnTranasction = conConnection.BeginTransaction
        comCommand.Transaction = trnTranasction

        comCommand.CommandText = "YOU INSERT/UPDATE/DELETE QUERY"
        Try
            comCommand.ExecuteNonQuery()
            trnTranasction.Commit()
        Catch ex As Exception
            trnTranasction.Rollback()
        End Try

        conConnection.Close()

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question