Hello all,

I started a new project wich function is restoring a corrupted DB.

I started with making a backup of the original db and then trying to restore it again.
But when executing my code i get following error

IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

Anyone got an idea how to resolve this?

Functions:

Private Sub TableBackup()
        frmMain.ActiveForm.Text = "Alfa Restore"
        If Not IO.Directory.Exists(Dest) Then
            MessageBox.Show("Destination Not Reachable")
            Exit Sub
        End If
        Dim name As String
        Dir = Dest & "\Backup\" & Now.Month & "-" & Now.Day & "-" & Now.Year
        If Not IO.Directory.Exists(Dir) Then
            IO.Directory.CreateDirectory(Dir)
        End If
        'Returns the type of schema table specified by the GetOleDbSchemaTable method
        Dim DBSchema As New OleDb.OleDbSchemaGuid
        Dim DBTableNames As New DataTable
        DBTableNames = DBConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
        DBDataSet.Clear()    ' remove previous data
        Dim DBTableRow As DataRow
        Dim SQLString As String
        For Each DBTableRow In DBTableNames.Rows
            If DBTableRow.Item("TABLE_TYPE") = "TABLE" Then
                name = CStr(DBTableRow.Item("TABLE_NAME"))
                SQLString = "Select * from " & name
                DBDataAdapter.SelectCommand = New OleDb.OleDbCommand(SQLString, DBConnection)
                DBCommandBuilder = New OleDb.OleDbCommandBuilder(DBDataAdapter)
                ' get data from the database and put them in memory
                Try
                    DBDataAdapter.Fill(DBDataSet, name)
                Catch eror As Exception
                    MessageBox.Show(eror.Message)
                Finally
                    DBCommandBuilder.Dispose()
                    DBDataAdapter.Dispose()
                    DBConnection.Close()
                End Try
            End If
        Next
        Try
            DBDataSet.WriteXml(Dir & "\BackUp.xml")
            DBDataSet.WriteXmlSchema(Dir & "\BackUp.xsd")
            Shell("""..\\gzip.exe"" -rqf """ & Dir & """", , True)
        Catch e As Exception
            MessageBox.Show("Paste gzip.exe in your Folder.")
        End Try
        frmMain.ActiveForm.Text = "Alfa Restore"
    End Sub
    Public Sub restore(ByVal dat As Date, Optional ByVal Encrypt As Boolean = False, Optional ByVal key As String = "")
        frmMain.ActiveForm.Text = "Waiting"
        Try
            Shell("""..\\gzip.exe"" -drqf """ & Dest & "\Backup\" & dat.Month & "-" & dat.Day & "-" & dat.Year & """", , True)
        Catch e As Exception
            MessageBox.Show("No Restore folder on " & dat & " in your " & Dest & " Folder")
            Exit Sub
        End Try
        Dim name As String
        Dir = Dest & "\Backup\" & dat.Month & "-" & dat.Day & "-" & dat.Year
        Call connection()
        DBConnection.Open()
        Dim DBSchema As New OleDb.OleDbSchemaGuid
        Dim DBTableNames As New DataTable
        DBTableNames = DBConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
        Dim DBTableRow As DataRow
        Dim SQLString As String
        'DBDataSet.Clear()
        DBNewDS.ReadXmlSchema(Dir & "/BackUp.xsd")
        DBNewDS.ReadXml(Dir & "/BackUp.xml")
        DBDataSet.Clear()
        DBDataSet.Merge(DBNewDS, True)
        For Each DBTableRow In DBTableNames.Rows
            If DBTableRow.Item("TABLE_TYPE") = "TABLE" Then
                name = CStr(DBTableRow.Item("TABLE_NAME"))
                SQLString = "Select * from " & name
                DBDataAdapter.SelectCommand = New OleDb.OleDbCommand(SQLString, DBConnection)
                ' get data from the database and put them in memory
                Try
                    Dim DBUpdateCommand As New OleDb.OleDbCommandBuilder(DBDataAdapter)
                    DBDataAdapter.Update(DBDataSet, name)
                Catch eror As Exception
                    MessageBox.Show(eror.Message & ".source=" & eror.Source & "in table" & name)
                Finally
                    DBDataAdapter.Dispose()
                    DBConnection.Close()
                End Try
            End If
        Next
        Try
            Shell("""..\\gzip.exe"" -rqf """ & Dest & "\Backup\" & dat.Month & "-" & dat.Day & "-" & dat.Year & """", , True)
        Catch e As Exception
            MessageBox.Show("No Restore folder on " & dat & " in your " & Dest & " Folder")
            Exit Sub
        End Try
        frmMain.ActiveForm.Text = "Alfa Restore"

Thanks in advance!

Recommended Answers

All 3 Replies

You might have a FieldName which is the same as one of the keywords. Try putting
brackets around the FieldName and see if that fixes it :)

Thank you for responding JJCollins.
I think it's something with my shell command. I never tried the shell before, so maybe there is something i'm doing wrong.

You are using relative paths to gzip.exe and, depending on the starting folder of you application, this call can fail. Try to set the full path to gzip.exe .

Also be sure that the path Dest & "\Backup\" already exists.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.