Solved

Delayed write to an Access db.

Posted on 2011-03-11
1
234 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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