SoFunction
Updated on 2025-04-08

Read the registry to get database connection fields based on the Office version

Read the registry to get database connection fields based on the Office version

Updated: July 24, 2014 16:05:14 Submission: whsnow
This section mainly introduces how to obtain the database connection field according to the Office version to read the registry and obtain the Office version. The implementation code is as follows. Interested friends should not miss it.
/// <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; 
}
  • Registration form
  • Office version

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-09
  • Access 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-06
  • Get the names of all tables in ACCESS2000 database

    Get the names of all tables in ACCESS2000 database...
    2006-11-11
  • Access Use Query Notes on Executing Calculations in Query

    Access uses query precautions for performing calculations in queries...
    2006-11-11
  • Tips 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-07
  • Access 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-11
  • Compression 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-11
  • Resolve 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-11
  • Access uses query--1.1. Create calculated fields with select query

    Access uses query--1.1. Create calculated fields with select query...
    2006-11-11
  • Create 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

Latest Comments