开发者

Ado dot netconnection String with Access 2007

I am trying to connect开发者_C百科 with Access 2007 "accdb" file using ADO net using the following code, but i am getting the error Unrecognized Database format, What can be the possible reason for this?

        OleDbConnection conn = new 
        OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;
        Data Source=C:/MyWorkers.accdb");

        try
        {
            conn.Open();
            MessageBox.Show("Connected");


        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }


You can use the Microsoft.ACE.OLEDB.12.0 provider, see http://www.connectionstrings.com/access-2007 available as part of the office 2007 system driver package.


try this connection string : Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;


Ensure that the database isn't corrupt. Repair it if necessary.

  1. Open the database in Access 2007.
  2. Go to the Tools menu, select Database Utilities and then click Compact and Repair Database.
  3. Locate and then click the database in the ‘Database to Compact From’ dialog box, and then click Compact.
  4. Select an appropriate folder location for the new file in the ‘Compact Database Into’ dialog box, type a unique name for the file and then click on Save.

Use your code to open the compacted database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜