Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

VB6-Access2003 Compact Repair Archive/Backup

 
   Database Help (Home) -> Visual Basic RSS
Next:  Saving current settings in Access  
Author Message
fallguy

External


Since: Feb 12, 2005
Posts: 1



(Msg. 1) Posted: Sat Feb 12, 2005 3:26 pm
Post subject: VB6-Access2003 Compact Repair Archive/Backup
Archived from groups: comp>lang>basic>visual>database (more info?)

Greetings,

I've created a VB front end to Access 2003 database application. Everything
works great, but I want to add database maintenace routines to the
application. Now to do the maintenace routines directly from Access seems
simple enough, built in Access menu choices. But my question is, what is
the best school of thought for database maintenance, directly from Access
or write maintenance procedures into my VB front end?

If VB is the best choice, I'm not sure how to go about it, what are my
options?

Thanks for your help.

fall

 >> Stay informed about: VB6-Access2003 Compact Repair Archive/Backup 
Back to top
Login to vote
dhodgkins

External


Since: Feb 15, 2005
Posts: 3



(Msg. 2) Posted: Tue Feb 15, 2005 6:10 am
Post subject: Re: VB6-Access2003 Compact Repair Archive/Backup [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

fallguy.RemoveThis@easystreet.com wrote:
 > Greetings,
 >
 > I've created a VB front end to Access 2003 database application.
Everything
 > works great, but I want to add database maintenace routines to the
 > application. Now to do the maintenace routines directly from Access
seems
 > simple enough, built in Access menu choices. But my question is,
what is
 > the best school of thought for database maintenance, directly from
Access
 > or write maintenance procedures into my VB front end?
 >
 > If VB is the best choice, I'm not sure how to go about it, what are
my
 > options?
 >
 > Thanks for your help.
 >
 > fall


Personally, I would use VB from your app just for sake of ease.
Compacting from VB is very easy.

1. Make a reference to Microsoft DAO 3.6 Object Library. We will be
using the DBEngine.
3. Dimension 2 strings to hold the FQN of the database you want to
compact and a temporay FQN name to call it during compaction. In the
code sample below, I am going to compact a database in my C:\Program
Files\ABS directory called ABSInfo.mdb.

Dim strDB1 as String, strDB2 as String
strDB1 = "C:\Program Files\ABS\ABSInfo.mdb"
strDB2 = "C:\Program Files\ABS\ABSInfo_Temp.mdb"

3. Now, if you use user level security on your database, you will need
to pass in the path to your workgroup file (system.mdw) as shown below.
If you do not use user level security, you can skip the code block
below.

With DBEngine
.SystemDB = "C:\Program Files\ABS\system.mdw"
.DefaultUser = "ABSAdmin"
.DefaultPassword = "ABSADMIN_Password"
End With

4. Next, the following line of code will compact the database in strDB1
into a new database with the name in strDB2.

DBEngine.CompactDatabase strDB1, strDB2

5. Finally, remove the database listed in strDB1 and rename the
database in strDB2 back to the name assigned to strDB1.

Kill strDB1
Name strDB2 As strDB1

6. Make sure to use proper error handling during this procedure to make
sure that the database listed in strDB1 is not deleted unless the
compaction is successful. This can be done with either an On Error Goto
statement at the begining of the function or On Error Resume Next at
the begining with an "If Err.Number = 0 then" statement before "Kill
strDB1" and the End If after the Name statement.

I also always recommend that a database be compacted before doing a
nightly backup (a database should always be backed up anytime a change
is made). Hope this helps.

David Hodgkins
MCSD, MCDBA, MCSE

 >> Stay informed about: VB6-Access2003 Compact Repair Archive/Backup 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table "PriceList" and there a column "Pricemk" wich is data type "money". All data in this column is in form "10001,35". So why when...

arrays - is there a way to concatenate the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all

Possible Use of a Cursor - I have a complex query that I hope I can explain it well enough for everyone to understand. I have a table that contains information for work instructions. Contained in the table are "MACHINE_PROC" these are groupings of machining processes....

Scroll Bars - Is there a way to find the size of scrollbars on a system using Visual Basic 6.0? I know how to look and change them on the display properties, but I don't know how to access that information from within Visual Basic.
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]