Home Database Mysql Tutorial Enterprise Library连接Access数据

Enterprise Library连接Access数据

Jun 07, 2016 pm 03:36 PM
access enterprise library number connect

许多开发人员没有意识到Enterprise Library Data Application AccessBlock可以 连接 很多ADO.NET支持的 数据 库。一个常见的问题是:EnterpriseLibrary支持Access 数据 库吗?答案是肯定的。你也可以使用DAAB,通过OLEDB或ODBC 连接 Access 数据 库。 使用过

许多开发人员没有意识到Enterprise Library Data Application AccessBlock可以连接很多ADO.NET支持的数据库。一个常见的问题是:EnterpriseLibrary支持Access数据库吗?答案是肯定的。你也可以使用DAAB,通过OLEDB或ODBC连接Access数据库。

  使用过EnterpriseLibrary的都知道,我们把DAAB相关的配置信息写在配置文件中,所以我们只需修改配置文件就可以了。、


OLEDB:

    configSections>
        
section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    
configSections>
    
dataConfiguration defaultDatabase="ConnectionString"/>
    
connectionStrings>
  
add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Test.mdb" providerName="System.Data.OleDb" />
 
connectionStrings>


ODBC:

    configSections>
        
section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    
configSections>
    
dataConfiguration defaultDatabase="ConnectionString"/>
    
connectionStrings>
  
add name="ConnectionString" connectionString="Dsn=Test;" providerName="System.Data.Odbc" />
 
connectionStrings>


配置文件修改后就可以使用Database操作数据库了,代码如下:

Database database =
   DatabaseFactory.CreateDatabase();

DbCommand command 
=
   database.GetSqlStringCommand(
"SELECT FROM Customers");

DataSet customer 
= database.ExecuteDataSet(command);


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to disable background applications in Windows 11_Windows 11 tutorial to disable background applications How to disable background applications in Windows 11_Windows 11 tutorial to disable background applications May 07, 2024 pm 04:20 PM

How to disable background applications in Windows 11_Windows 11 tutorial to disable background applications

How to convert deepseek pdf How to convert deepseek pdf Feb 19, 2025 pm 05:24 PM

How to convert deepseek pdf

What does field mean in java What does field mean in java Apr 25, 2024 pm 10:18 PM

What does field mean in java

How does the Java reflection mechanism modify the behavior of a class? How does the Java reflection mechanism modify the behavior of a class? May 03, 2024 pm 06:15 PM

How does the Java reflection mechanism modify the behavior of a class?

How to cross-domain iframe in vue How to cross-domain iframe in vue May 02, 2024 pm 10:48 PM

How to cross-domain iframe in vue

Common exception types and their repair measures in Java function development Common exception types and their repair measures in Java function development May 03, 2024 pm 02:09 PM

Common exception types and their repair measures in Java function development

How to read dbf file in oracle How to read dbf file in oracle May 10, 2024 am 01:27 AM

How to read dbf file in oracle

Top 10 Global Digital Virtual Currency Trading Platform Ranking (2025 Authoritative Ranking) Top 10 Global Digital Virtual Currency Trading Platform Ranking (2025 Authoritative Ranking) Mar 06, 2025 pm 04:36 PM

Top 10 Global Digital Virtual Currency Trading Platform Ranking (2025 Authoritative Ranking)

See all articles