none
Access 2007 Visual studio 2012 RRS feed

  • General discussion

  • I cant connect data base. I keep getting error saying "Unrecognized database format"
    • Changed type Fred BaoModerator Friday, December 20, 2013 11:30 AM It is an open thread
    Wednesday, December 11, 2013 6:54 PM

All replies

  • Which engine did you use? The 2007 db has a new format that won't be recognized by old engines like Jet4


    Visual C++ MVP

    Wednesday, December 11, 2013 9:47 PM
  • Hello MifaMichal,

    Could you please more information regarding this issue as your connection string, the codes which throw this error and your program environment?

    With these information, I think this issue would get a better solution.

    For the error message “Unrecognized database format”, there are some regarding threads, you can take a look.

    http://stackoverflow.com/questions/13884080/corrupted-access-accdb-file-unrecognized-database-format

    http://social.msdn.microsoft.com/Forums/office/en-US/7ba31e1a-7852-424d-bffb-53d8839939be/unrecognized-database-format-access-vba?forum=accessdev

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 12, 2013 7:32 AM
    Moderator
  • You need to specify the ACE OLEDB Provider in your connection string. See example at below link:

    http://www.connectionstrings.com/access/


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, December 12, 2013 1:29 PM
  • Hello,

    Here is an example using a language extension method that sets the connection string dependent on the file extension. If this fails then there is something else going on.

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim File1 As String = "C:\Data\CustomersMain.accdb"
    
            Using cn As New OleDb.OleDbConnection With {.ConnectionString = File1.BuildConnectionString}
                cn.Open()
            End Using
    
            Dim File2 As String = "C:\Data\NorthWind.mdb"
            Using cn As New OleDb.OleDbConnection With {.ConnectionString = File2.BuildConnectionString}
                cn.Open()
            End Using
    
            MessageBox.Show("Done")
        End Sub
    End Class
    

    Extension method

    Module DatabaseConnectionDynamic
        <System.Diagnostics.DebuggerStepThrough()> _
        <System.Runtime.CompilerServices.Extension()> _
        Public Function BuildConnectionString(ByVal DatabaseName As String) As String
    
            If IO.Path.GetExtension(DatabaseName).ToLower = ".accdb" Then
    
                Dim Builder As New OleDb.OleDbConnectionStringBuilder With
                    {
                        .Provider = "Microsoft.ACE.OLEDB.12.0",
                        .DataSource = DatabaseName
                    }
    
                Return Builder.ConnectionString
    
            ElseIf IO.Path.GetExtension(DatabaseName).ToLower = ".mdb" Then
    
                Dim Builder As New OleDb.OleDbConnectionStringBuilder With
                    {
                        .Provider = "Microsoft.Jet.OLEDB.4.0",
                        .DataSource = DatabaseName
                    }
    
                Return Builder.ConnectionString
    
            Else
    
                Throw New Exception("File type not supported")
    
            End If
    
        End Function
    End Module
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Tuesday, December 31, 2013 8:06 PM