Visual Basic.NET - módulo para compactar una BD

 
Vista:
sin imagen de perfil
Val: 344
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

módulo para compactar una BD

Publicado por Miguel (281 intervenciones) el 16/10/2015 14:46:07
Tengo este módulo para compactar una BD y me da un error diciendo que no se puede implementar esa operación. He dedicado una semana a ver en la red módulos parecido pero todos me dan error en la misma función. Si alguien conoce el problema ó que lo haya sufrido agradecería cualquier ayuda para entender el problema.

Error en la linea : jro.CompactDatabase(File_Path, File_compact)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Imports System.IO
 
Module modCompactar
    Public Sub Compactar()
        Dim jro As jro.JetEngine = Nothing
        Try
            Dim File_Path As String 'Path del fichero original a compactar
            Dim File_compact As String  'Fichero compactado
            File_Path = AppDomain.CurrentDomain.BaseDirectory & clsInicio.Inicio.clsInicio.BD
            File_compact = AppDomain.CurrentDomain.BaseDirectory & clsInicio.Inicio.clsInicio.Backup
            If ExisteFile(File_Path) = True Then   'Verificar que exste el fichero a compactar.
                jro = New jro.JetEngine()
                jro.CompactDatabase(File_Path, File_compact)
            End If
            If ExisteFile(File_compact) Then  'Restaurar el Original del fichero compactado.
                File.Delete(File_Path)
                File.Move(File_compact, File_Path)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            ' Disminuimos el contador de referencias y liberamos el objeto.
            Runtime.InteropServices.Marshal.ReleaseComObject(jro)
            jro = Nothing
        End Try
    End Sub
 
    Public Function ExisteFile(ByVal Fichero As String) As Boolean
        Dim existe As Boolean
        existe = System.IO.File.Exists(Fichero)
        Return existe
    End Function
End Module

Gracias y un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder