Read the registry to get database connection fields based on the Office version
/// <summary> /// Read the registry and obtain the database connection field according to the Office version/// </summary> /// <returns>Database Connection Field</returns>private string GetConnectionString() { string strConnectionString = "Provider=.4.0;Data Source = "; RegistryKey rk = ; //Query Office2003 RegistryKey f03 = (@"SOFTWARE\Microsoft\Office\11.0\Access\InstallRoot\"); //Query Office2007 RegistryKey f07 = (@"SOFTWARE\Microsoft\Office\12.0\Access\InstallRoot\"); //Query Office2010 RegistryKey f10 = (@"SOFTWARE\Microsoft\Office\14.0\Access\InstallRoot\"); if (f03 != null) { strConnectionString = "Provider=.4.0;Data Source = "; } else if (f07 != null || f10 != null) { strConnectionString = "Provider=.12.0;Data Source = "; } return strConnectionString; }
Related Articles
Access creates a simple MIS management system
The so-called MIS management system is a system composed of people, computers and other peripheral devices that can collect, transmit, store, process, maintain and use information. MIS management system is an emerging technology, so the following article will introduce to you how to create a simple MIS management system, Access, a historical database system.2015-09-09Access Methods for executing SQL
How to execute Sql in Access? Although it reduces the workload with interfaces, I am still used to executing SQL.2009-06-06Get the names of all tables in ACCESS2000 database
Get the names of all tables in ACCESS2000 database...2006-11-11Access Use Query Notes on Executing Calculations in Query
Access uses query precautions for performing calculations in queries...2006-11-11Tips to use SQL statements to find out whether a table exists in Access
It is indeed difficult to find whether a table exists through SQL statements in the Access database. Follow the steps below and check whether the table exists through SQL statements in the program.2014-07-07Access uses macro control program--1.6. Several explanations for using macros
Access uses macro control program--1.6. A few instructions on using macros...2006-11-11Compression and repair methods of ACCESS database files [Pictures and texts]
This page introduces simple compression and repair functions. Online compression is prone to problems, so you can finally implement it locally.2010-11-11Resolve an error that was not specified by Microsoft JET Database Engine (0x80004005) in Access
When we use the access database, we sometimes encounter unspecified errors of Microsoft JET Database Engine (0x80004005). Generally, this error is a permission problem. Today we will discuss the solution in detail.2014-11-11Access uses query--1.1. Create calculated fields with select query
Access uses query--1.1. Create calculated fields with select query...2006-11-11Create free accounting date reports-1.4. Let reports process data between the beginning and end of the period
Establish free accounting date reports-1.4. Let the reports process data between the beginning and end of the period...2006-11-11