Jim Fell
Jim Fell

Reputation: 14256

Error Opening Access Database with C# Application

I'm updating a C# (.NET 3.5) application to interact with an Access database, but I keep getting this error:

ERROR: Unrecognized database format

This is the code I'm using to open a connection to the database:

        String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " +
            "Data Source=" + filePath;

        try
        {
            this.conn = new OleDbConnection(connectionString);
            this.conn.Open();
        }
        catch (Exception e)
        {
            Console.WriteLine("ERROR: " + e.Message);
            Console.WriteLine(e.ToString());
        }

I know that the file path is correct. I suspect that the Provider=Microsoft.Jet.OLEDB.4.0; is incorrect. How do I find out what the database format is? I did not make the database in question, but I do have read-access to it. Thanks.

Upvotes: 0

Views: 646

Answers (1)

Sergey Gazaryan
Sergey Gazaryan

Reputation: 1043

You must add Data Source , user/password parametters . You can see http://connectionstrings.com/access

Upvotes: 1

Related Questions