Solved

Delayed write to an Access db.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now