就ACESS 、SQL2005以及ORACLE进行分别说明和综合配置说明
希望能给初了解的人有所帮助
SQL2005--------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<dataConfiguration defaultDatabase="SQLCONN" />
<connectionStrings>
<add name="SQLCONN" connectionString="Data Source=PERRY;Initial Catalog=MuOnline;Persist Security Info=True;User ID=sa;Password=xiexiaopeng"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
创建实例:
Database db = DatabaseFactory.CreateDatabase("SQLCONN");
string sqlCommand = "Select * " + "From UserLogin";
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
ACESS 2003--------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<dataConfiguration defaultDatabase="ACESSCONN" />
<connectionStrings>
<add name="ACESSCONN" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:LifeEasyLifeEasyDataBaseLifeEasyDataBase.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
创建实例:
Database db = DatabaseFactory.CreateDatabase("ACESSCONN");
string sqlCommand = "Select * " + "From [User]";
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
ACESS and SQL2005-------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<dataConfiguration defaultDatabase="ACCESSCONN" />
<connectionStrings>
<add name="ACCESSCONN" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:LifeEasyLifeEasyDataBaseLifeEasyDataBase.mdb"
providerName="System.Data.OleDb" />
<add name="SQLCONN" connectionString="Data Source=PERRY;Initial Catalog=MuOnline;Persist Security Info=True;User ID=sa;Password=xiexiaopeng"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>