Commit of Record insertion Access.mdb

From: Marc Doolittle (marcd_at_info-link.com)
Date: 01/21/05


Date: Fri, 21 Jan 2005 11:12:01 -0500

In vb.net I have a subroutine that calls two functions
Public Sub Test()
InsertRecords()
msgbox(GetCountRecords())
end Sub

Insert records loops through a text file and inserts records into an
Access.mdb table.

GetCountRecords just fills a dataset object with a DataAdapter to return a
count from the Access database of the recently inserted records. The code
is not important I don't thnk- I have changed it 1000 differnet ways and
still get this problem- My problem-

1/10 to 1/2 of the time (randomly) the GetCount procedure returns 0 records
inserted when in fact there were records inserted. If I put a breakpoint in
the da.fill(ds) line that fills the dataset in debug it always returns a
number of records but running the exe it occasionally returns 0. Each
procedure has a separate connection to the database. I have tried multiple
ways to correct this problem. Using transactions, using Datasets to update
the records versus inserting with an SQL command, using DataReaders rather
than filling a dataset. Disposing, forcing garbage collection. The only fix
so far is to put a thread.currentthread.sleep(10000) before the GetCount
procedure. In other words for some reason (threading? Garbage Collecting?)
ADO.net needs to "Wait" until the correct count will return. This solution
is inadequate. Any ideas? Marc



Relevant Pages

  • Re: Format "0000"
    ... worksheet and inserting them into an Access database. ... Dim Rng As Range ... For Each Rng In Selection ...
    (microsoft.public.excel.programming)
  • Re: Format "0000"
    ... worksheet and inserting them into an Access database. ... I have tried using the custom format, and you're right, it only ... For Each Rng In Selection ...
    (microsoft.public.excel.programming)
  • RE: Date/Time Strange Problem
    ... "Shapper" wrote: ... > I am having an error when inserting a record in an Access database. ... > I get the error "Data type mismatch in criteria expression." ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: OleDbDataAdapter question
    ... I would rather use a DataReader to read the records and at the same time ... inserting these records in the second DB. ... Ignacio Machin, ... > I want to copy some record from a Access database to another Access DB. ...
    (microsoft.public.dotnet.languages.csharp)
  • JDBC commit problem
    ... I am working with MS Access database through JDBC. ... The problem arises when I want to view my table just after inserting ... (name, value, prize, date) ...
    (comp.lang.java.databases)