Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Access Database with my VB6 project... DB corrupts

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
US
I have an access database that I use with my vb6 application. I have about 50 user's accessing this data at one time. About once or twice a month, the database will corrupt, and I will have to repair it. Sometimes the repair wont work, and I have a useless database.

Is this most likely a problem with my code, or do I need to use a different database system? (MSDE?)

Thanks
 
You should be compacting and repairing the database every night. Also, you may want to look into MSDE as 50 users is a lot for Access to handle at once. Are you seeing any performance issues such as speed issues?

Swi
 
I'm not seeing any speed issues. This application only runs at user login & logout.. It closes the db connection while running, then re-opens it at logout. I'll bet that at most, there are 10 concurrent connections to this db.
 
Just try writing some code to Compact and Repair the database in the evening then. It sounds to me like it is not done frequently enough.

Swi
 
Swi, I think mark01 is right, we had a similar issue, contacted MS and figured out that it was a problem on their end (I don't remember the specifics). The solution was to compact and repair the db every day or so.
-Max
 
Sub CompactDB()
On Error GoTo CompactDB_Err
Const conFilePath = "C:\Windows\My Database\"

' Compact the database to a temp file.
DBEngine.CompactDatabase "C:\Windows\My Database\manojvb.mdb", "C:\Windows\My Database\manojvb1.mdb"

' Delete the previous backup file if it exists.
If Dir(conFilePath & "manojvb.bak") <> "" Then
Kill conFilePath & "manojvb.bak"
End If

' Rename the current database as backup and rename the temp file to ' the original file name.
Name conFilePath & "manojvb.mdb" As conFilePath & "manojvb.bak"
Name conFilePath & "manojvb1.mdb" As conFilePath & "manojvb.mdb"
MsgBox "Compacting is complete"

Exit_CompactDB:
Exit Sub

CompactDB_Err:
MsgBox Err.Description
Resume Exit_CompactDB
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top