An exception occurred while accessing an unrecognized database connected to accdb.

Source: Internet
Author: User
The database suffix names before Access07 are *. and the connection string is written as ProviderMicrosoft. jet. OLEDB.4.0; performancec: myFolder *. mdb; PersistSecurityInfoFalse; but Access07 and Access10 change the suffix *. accdb. Through the above connection, an unrecognized database will be reported.

The database suffix names before Access07 are *. mdb and the connection string is written as Provider = Microsoft. jet. OLEDB.4.0; Data Source = C: \ myFolder \*. mdb; Persist Security Info = False; but Access07 and Access10 change the suffix *. accdb. Through the above connection, an "Unrecognized database will be reported

The database extension names before Access07 are *. mdb, and the connection string is written as Provider = Microsoft. Jet. OLEDB.4.0; Data Source = C: \ myFolder \ *. mdb; Persist Security Info = False;

However, Access07 and Access10 change the suffix to *. accdb. When the above connection is used, an "Unrecognized database format" exception will be reported.

Note that the Oledb connection mode of Microsoft. Jet. OLEDB.4.0 is relatively old, And the Oledb connection mode after 07 will be changed to Microsoft. ACE. OLEDB.12.0.

The changed connection is Provider = Microsoft. ACE. OLEDB.12.0; Data Source = C: \ myFolder \ *. accdb; Persist Security Info = False;



Tips for beginners:

In asp.net, the connection string is often written in web. config. However, the access connection string is the absolute location of the database. That is, the drive letter:/folder/file, which leads to the need to change the path after the file is copied. In fact, you can use a program to obtain the absolute path of the database file. The details are as follows:

In web. config, only the database file name is written (the database file is usually put in the App_Data folder, because of the security)

 
 
  

Write the following method to obtain the string in the DBHelper class:

 public static string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + AppDomain.CurrentDomain.BaseDirectory + ConfigurationSettings.AppSettings["ConnString"];

Obtain the absolute path of the database through AppDomain. CurrentDomain. BaseDirectory.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.