Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Compacting Error


Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2000, 04:26 AM
murphyt
Guest
 
Posts: n/a
Question Compacting Error


I am using VB6 Pro with SP4 and use Access 97 & Win ME.
When I try to compact database using following code I get,

Error 3356
You attempted to open a database that is already open exclusively by user 'admin' on computer 'spud'.
Try again when the database is available.

Code

Dim db As Database

Set db = DBEngine.Workspaces(0).OpenDatabase _("c:\shop\stock.mdb")

db.Close

DBEngine.CompactDatabase "c:\shop\stock.mdb", _
"c:\shop\new.mdb","

Name "c:\shop\stock.mdb" As "c:\shop\old.mdb"
Name "c:\shop\new.mdb" As "c:\shop\stock.mdb"

End Sub

Please tell me where I am going wrong as nothing in VB Code or Access says database is for exclusive use ( that I can find )
I have used this code before and now doesn't want to work after doing the updates to VB.

Many thanks,
Trevor


Reply With Quote
  #2  
Old 12-17-2000, 12:17 PM
jar
Guest
 
Posts: n/a
Default Re: Compacting Error

You might try deleting the statement:
Set db = DBEngine.Workspaces(0).OpenDatabase _("c:\shop\stock.mdb")

Reply With Quote
  #3  
Old 12-18-2000, 09:24 AM
BoghRD
Guest
 
Posts: n/a
Default Re: Compacting Error

Ah yesss.......

Compressing files, renaming files, and/or deleting files all require EXCLUSIVE access to the database in question. You must open the database exclusively to perform these tasks. However, comma, the CompactDatabase method/statement cannot even be used by THE client that has the file openned exclusively.

The best concept I've found (an god almighty I hope someone has a better algorithm) is to open the file exclusively, quickly close it, and then run the CompactDatabase method, then close it again.

Also, be aware that if some chump has the file openned in Access you will get this error as well.

Later,

Roger Bogh
Yak & Quack Software Incorporated...
Reply With Quote
  #4  
Old 12-18-2000, 09:38 AM
whelanp
Guest
 
Posts: n/a
Default Re: Compacting Error

A copy of FMS Total Access Agent sorts all known problems with compacting and backing up Access Dbs.

Worth every penny.

Reply With Quote
  #5  
Old 12-18-2000, 03:49 PM
murphyt
Guest
 
Posts: n/a
Default Re: Compacting Error

Where do I get a copy of FMS Total Access Agent ?

Reply With Quote
  #6  
Old 12-19-2000, 02:23 AM
whelanp
Guest
 
Posts: n/a
Default Re: Compacting Error

FMS are a software company that produce "stuff" for Access and VB developers.

Some of it is fairly pricey but the quality is 100%.

Do a few Web searchs your bound to find their Site.





Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->