Free space used in BBDD Access

1

I am making an application in VB.net (4.5) using as BBDD Access (2016), but I have a small problem: when I insert a record (for example, a Richtextbox converted to Byte ()) the size of the DB increases. But when I eliminate it, the size does not diminish (it stays as it was). Therefore, as I insert and delete records the DB does not stop growing in MB.

I have been able to verify that when I restart the PC, the DB does "free up" space. What could be the reason?

PS: I'm doing the .close() and .dispose() needed in my access class to BBDD.

    
asked by sertarba 19.02.2016 в 09:40
source

2 answers

1

The problem I see with this compaction is when to do it. The application will allow you to create new DBs to suit the user, and you can place them where you want. Therefore:

  • I do not know what DB there is, since it is not fixed.
  • Also, the databases can be used by several users, so if I start to compact while there are users inside ...
  • When to compact? As long as a DELETE is done?
answered by 19.02.2016 в 19:58
0

What happens is that Ms Access does not free space, so you must compact

How to compact an Access database with JRO

As you will notice, a library other than ADO.NET is used, so you will have to add the reference to Microsoft Jet and Replication Object 2.6 Library

The code is quite simple, since it only involves invoking the CompactDatabase() method, but two connection string must be indicated, because when compacting, generate the dump to a new db that you can then rename

Dim jro As JRO.JetEngine = New JRO.JetEngine()

' Compactamos la base de datos
'
jro.CompactDatabase(connStringOrigen, connStringDestino)

Runtime.InteropServices.Marshal.ReleaseComObject(jro)

The Marshal.ReleaseComObject is important to correctly release resources from a COM instance

    
answered by 19.02.2016 в 12:22