/// <summary>
/// 内部保护的数据库连接类
/// </summary>
protected abstract class Provider
{
//一个静态的连接接口;
private static System.Data.IDbConnection conn;
/// <summary>
/// 构造方法,设为私有类型,是防止外部无效的引用;
/// </summary>
protected Provider()
{
System.Data.IDbCommand x=new System.Data.OleDb.OleDbCommand();
}
/// <summary>
/// 返回数据库边接类型
/// </summary>
public static DBType Type
{
get
{
return Provider.m_DBType;
}
set
{
Provider.m_DBType=value;
}
}
private static string m_ConnectionString;
private static string m_ConnectionStringSetName;
/// <summary>
/// 数据库连接字符串设置名称
/// </summary>
public static string ConnectionSetName
{
set
{
Provider.m_ConnectionStringSetName=value;
}
}
/// <summary>
/// 数据库连接字符串
/// </summary>
public static string ConnectionString
{
set
{
Provider.m_ConnectionString=value;
}
}
private static DBType m_DBType;
/// <summary>
/// 获得数据库连接接口
/// </summary>
/// <returns>返回一个连接</returns>
public static System.Data.IDbConnection getConn()
{
string ConnStr="";
try{
//System.Threading.Thread.GetDomain().UnhandledException+=new UnhandledExceptionEventHandler(ThrowDBException);
if(Provider.m_ConnectionString==""||Provider.m_ConnectionString==null)
{
if(Provider.m_ConnectionStringSetName.Trim()=="")
{
ConnStr=System.Configuration.ConfigurationSettings.AppSettings["DataBase.ConnectionString"];
}
else
{
ConnStr=System.Configuration.ConfigurationSettings.AppSettings[Provider.m_ConnectionStringSetName];
}
}
else
{
ConnStr=Provider.m_ConnectionString;
}
if(ConnStr==null||ConnStr=="")
{
throw new JoyBaseDBException("连接字符串为空或者是null类型,请检查您的ConnectionString以及ConnectionSetName是否进行正确设置,或者阅读相关说明.");
}
&nb