asp.net 多数据库支持的思考

一般的多数据库支持在配置文件中如下:

代码如下:

<connectionStrings> 
<add name="MyCmsConnectionString" connectionString="server=(local);user id=sa;pwd=123456;database=mycms;"/> 
</connectionStrings>

而数据库连接如下:

代码如下:

using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Configuration; 
using System.Data; 
using System.Data.Common; 
namespace COMMON 
{ 
public class Class1 
{ 
public DbConnection GetDatabaseConnection() 
{ 
ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["Conn"]; 
DbProviderFactory factory = DbProviderFactories.GetFactory(settings.ProviderName); 
DbConnection conn = factory.CreateConnection(); 
conn.ConnectionString = settings.ConnectionString; 
return conn; 
} 
} 
}

但接下来呢?研究了discuz和其他一些支持多数据库的cms,有一些想法。

相关推荐