Solved

Delayed write to an Access db.

Posted on 2011-03-11
1
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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