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.