473,500 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoiding VBA corruption; best practices?

Hello,

I have been experiencing crashes and code corruption in my project
(vbe6.dll; a decompile fixes the corruption); for the life of me I
cannot figure out why, and I can't pin down the offending code because
each crash immediately shuts down the database and forces me to
recompile in order to open it again. I am following proper coding
procedures, e.g. creating and destroying objects properly (AFAIK),
closing adodb recordsets before reusing them, etc.. Are there any
guidelines for avoiding code corruption, or is it just a crap-shoot?

I thought perhaps techniques I am using are not proper, such as
executing all my in-code queries via 'recordset = connection.Execute
SQL text' (instead of calling a precompiled query in the queries
collection - even complex queries, with multiple joins); re-using
recordset objects; using err.Raise extensively; reDimming arrays who's
size I don't know at compile time.
I've also created a class to implement a key/value hash, which I pass
to one function via a parameter array (I don't know how many hashes I
need at compile time).

Does anyone have any insight/guidelines regarding how to prevent code
corruption?

Thanks you immensely.
-Robert Waters

Sep 23 '06 #1
5 3896
Maybe some of MVP Allen Browne's suggestions will be helpful.
Preventing corruption: http://allenbrowne.com/ser-25.html

ro***********@gmail.com wrote:
>Hello,

I have been experiencing crashes and code corruption in my project
(vbe6.dll; a decompile fixes the corruption); for the life of me I
cannot figure out why, and I can't pin down the offending code because
each crash immediately shuts down the database and forces me to
recompile in order to open it again. I am following proper coding
procedures, e.g. creating and destroying objects properly (AFAIK),
closing adodb recordsets before reusing them, etc.. Are there any
guidelines for avoiding code corruption, or is it just a crap-shoot?

I thought perhaps techniques I am using are not proper, such as
executing all my in-code queries via 'recordset = connection.Execute
SQL text' (instead of calling a precompiled query in the queries
collection - even complex queries, with multiple joins); re-using
recordset objects; using err.Raise extensively; reDimming arrays who's
size I don't know at compile time.
I've also created a class to implement a key/value hash, which I pass
to one function via a parameter array (I don't know how many hashes I
need at compile time).

Does anyone have any insight/guidelines regarding how to prevent code
corruption?

Thanks you immensely.
-Robert Waters
--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1

Sep 23 '06 #2
For the sake of posterity, I'd like to post what I've found to be a
useful resource on this subject:

http://www.vba-programmer.com/Snippe...Stability.html

It advises the conservative use of recordsets, and then only
adOpenForwardOnly and adLockReadOnly.

To quote the author:
"The primary reason for database corruption (in a multi-user setting)
is an
interrupted write operation. When the JET database begins to write
a record,
a flag is set, if the operation is interrupted before the flag is
reset -- the
database is considerred corrupt. New Users cannot log in, and the
current Users
must be logged out so the database can be compacted/repaired."

Also, there were some excellent topics on the experts-exchange website
regarding Access DB corruption.

And thanks for your help, ruralguy.

-Robert

Sep 26 '06 #3
"robert.waters" wrote
For the sake of posterity, I'd like to post
what I've found to be a useful resource
on this subject:

http://www.vba-programmer.com/Snippe...Stability.html
>
It advises the conservative use of recordsets, and then only
adOpenForwardOnly and adLockReadOnly.
<SNIP>

I don't know who vba-programmer may be, but that particular advice is not
very good.

By extension, the most stable Access database would be one that did nothing
and was never opened. Of course, that would defeat the purpose of using
Access in the first place. Limiting use is not the answer to "interrupted
writes."

And, of course, if you limit use of recordsets, you'll have to do things
with Forms, and Queries, and such, and they, too, are subject to corruption
from "interrupted writes" which the writer of this advice apparently did not
consider.

The answer is to prevent interruption of the write operation:

(1) stabilize the network, so users do not experience
dropped connections that interrupt the writes.
(2) use a honkin' big uninterruptible power supply to
power servers, network, and user's machines, so
power outages don't interrupt the writes, and
(3) train users to shut down "gracefully," that is, to exit
the Access database application in the proper way
(usually a "Quit" button) and to exit Windows with
the software shutdown, not by turning off power
to their computer.

These, by observation of a good many Access users and developers, are the
three most common provable causes of corruption. But they are not the only
ones.

For other good information, see MVP Tony Toews' site,
http://www.granite.ab.ca/accsmstr.htm. At least, there, you know up front
who collected the information.

Larry Linson
Microsoft Access MVP
Sep 26 '06 #4
"robert.waters" <ro***********@gmail.comwrote in
news:11**********************@e3g2000cwe.googlegro ups.com:
For the sake of posterity, I'd like to post what I've found to be
a useful resource on this subject:

http://www.vba-programmer.com/Snippe...mber_One_Secre
t_for_Stability.html

It advises the conservative use of recordsets, and then only
adOpenForwardOnly and adLockReadOnly.

To quote the author:
"The primary reason for database corruption (in a multi-user
setting) is an
interrupted write operation. When the JET database begins to
write
a record,
a flag is set, if the operation is interrupted before the flag
is
reset -- the
database is considerred corrupt. New Users cannot log in, and
the
current Users
must be logged out so the database can be compacted/repaired."
That's about *data* corruption, not VBA project corruption.

So, it has zilch to do with what *I* thought the topic of this
thread was.

And, of course, it's silly advice, as no one with any brains woudl
use a recordset update when a SQL update can do the same thing. The
only time you edit data in a recordset is when it's not possible to
do it with straight SQL.

So, I'd say whoever created that site is an idiot.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 27 '06 #5
"robert.waters" <ro***********@gmail.comwrote in
news:11**********************@e3g2000cwe.googlegro ups.com:
Also, there were some excellent topics on the experts-exchange
website regarding Access DB corruption.
Is the topic database corruption or VBA project corruption? The
issues are completely separate, since a front end won't have any
data and a back end won't have any VBA project.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
9198
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
4
4600
by: DFS | last post by:
" has detected corruption in this file. To try to repair the corruption, first make a backup copy of the file. Then, on the Tools menu, point to Database Utilities and click Compact and Repair...
1
2188
by: tHeRoBeRtMiTcHeLL | last post by:
What is the best practice for dealing with many input forms that contain memo fields to capture exceptions and extra information ( an audit trail or updates field would be one example) needed as...
10
3415
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
3
2320
by: Richard | last post by:
Rather than all that painting, brush, etc. code to change the styles of a ..NET datagrid to start with and on the fly, I'd rather be able to set a lot of the stuff in the designer properties of the...
4
1432
by: andre.roberge | last post by:
I'm using a js script (approx. 300 lines) from someone else to create dynamically some web pages, using Python. Unfortunately, I am not familiar with javascript :-( I now want to reproduce the...
15
3715
by: Amir Michail | last post by:
Hi, Trying to open a file for writing that is already open for writing should result in an exception. It's all too easy to accidentally open a shelve for writing twice and this can lead to...
8
1618
by: Slez via AccessMonster.com | last post by:
I have read many resources regarding corruption, and implemented as much as possible to prevent it, but I have one user that encounders corruption of their front end database, when no-one else...
4
1614
by: Slez via AccessMonster.com | last post by:
I have a recurring corruption issue that appears to be stemming from a Memo field in a table. I have done extensive searching about this topic and have pretty much implemented all possible...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.