J
John W.
I've seen other posts with similar problems, but no solutions. I have two
hair-pulling dilemmas that have been frustrating me for months now. Is there
no solution? (C#.NET, Framework 2.0, Jet OleDb 4.0)
The general goal is to read one MDB file and copy relevant info into another
MDB file (copied from an empty template), replacing the old file with the new
file. DataAdapters are used only to read (or re-read) the data from the file
into the in-memory DataTable. All data INSERTs and UPDATEs are done with
OleDbCommand.ExecuteNonQuery().
Problem 1: To retain the original version of the file, the process requires
two rename operations. The first renames the original file. The second
renames the new file to have the original file's name. Half the files I
process do this OK. The other half fail on one of the renames, claiming that
the file is still locked by another process. Checking the directory just
prior to the rename attempt confirms that the corresponding LDB file still
exists when the rename fails and doesn't exist when it succeeds. I've gone
so far as to put all the data copying into a separate Main and invoking it
with a Process.Start() so that the locking process has to be terminated
before I attempt the rename. No dice. Aaaaargh!
Problem 2: In the last-called method of the copy process, one new record is
written to each of two empty tables. After that, a message is written to a
log file, the method returns, and the OleDbConnection is closed. All of that
occurs in about a dozen lines of code. This works almost all the time,
except on one of my test files. With that file, the first inserted row
appears in the output mdb file, but the second one does not! There is
nothing particularly unusual about this file; other test files have identical
structures. The tables involved are new tables, not present in the source
data file, and every test file requires that these two rows be created. No
errors are reported by the INSERTs or any other statement; it just doesn't
get committed to the table. Double-Aaaaargh!!
hair-pulling dilemmas that have been frustrating me for months now. Is there
no solution? (C#.NET, Framework 2.0, Jet OleDb 4.0)
The general goal is to read one MDB file and copy relevant info into another
MDB file (copied from an empty template), replacing the old file with the new
file. DataAdapters are used only to read (or re-read) the data from the file
into the in-memory DataTable. All data INSERTs and UPDATEs are done with
OleDbCommand.ExecuteNonQuery().
Problem 1: To retain the original version of the file, the process requires
two rename operations. The first renames the original file. The second
renames the new file to have the original file's name. Half the files I
process do this OK. The other half fail on one of the renames, claiming that
the file is still locked by another process. Checking the directory just
prior to the rename attempt confirms that the corresponding LDB file still
exists when the rename fails and doesn't exist when it succeeds. I've gone
so far as to put all the data copying into a separate Main and invoking it
with a Process.Start() so that the locking process has to be terminated
before I attempt the rename. No dice. Aaaaargh!
Problem 2: In the last-called method of the copy process, one new record is
written to each of two empty tables. After that, a message is written to a
log file, the method returns, and the OleDbConnection is closed. All of that
occurs in about a dozen lines of code. This works almost all the time,
except on one of my test files. With that file, the first inserted row
appears in the output mdb file, but the second one does not! There is
nothing particularly unusual about this file; other test files have identical
structures. The tables involved are new tables, not present in the source
data file, and every test file requires that these two rows be created. No
errors are reported by the INSERTs or any other statement; it just doesn't
get committed to the table. Double-Aaaaargh!!