用C#实现的数据库抽象工厂 (转载自chrch)

     最近学习了一下设计模式,便尝试用C#对数据库的访问操作采用抽象工厂的模式实现一下,其中与标准的模式略有不同,加入了一些自己的想法,希望大家批评指正,代码共分为6个类:

(1)AbstractDbFactory.cs
None.gif using  System;
None.gif
using  System.Data;
None.gif
None.gif
namespace  DbService
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// 数据库抽象工厂接口
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public interface AbstractDbFactory
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立默认连接
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>数据库连接</returns>

InBlock.gif  IDbConnection CreateConnection();
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据连接字符串建立Connection对象
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strConn">连接字符串</param>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  IDbConnection CreateConnection(string strConn);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立Command对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Command对象</returns>

InBlock.gif  IDbCommand CreateCommand();
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立DataAdapter对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>DataAdapter对象</returns>

InBlock.gif  IDbDataAdapter CreateDataAdapter();
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Connection建立Transaction
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbConnection">Connection对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>Transaction对象</returns>

InBlock.gif  IDbTransaction CreateTransaction(IDbConnection myDbConnection);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Command建立DataReader
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbCommand">Command对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>DataReader对象</returns>

InBlock.gif  IDataReader CreateDataReader(IDbCommand myDbCommand);
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 获得连接字符串
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>连接字符串</returns>

InBlock.gif  string GetConnectionString();
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif


(2)Factory.cs
None.gif using  System;
None.gif
using  System.Configuration;
None.gif
None.gif
namespace  DbService
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// Factory类
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public sealed class Factory
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
InBlock.gif  
private static volatile Factory singleFactory = null;
InBlock.gif  
private static object syncObj = new object();
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// Factory类构造函数
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  private Factory()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 获得Factory类的实例
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Factory类实例</returns>

InBlock.gif  public static Factory GetInstance()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
if(singleFactory == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
lock(syncObj)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     
if(singleFactory == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif     
dot.gif{
InBlock.gif      singleFactory 
= new Factory();
ExpandedSubBlockEnd.gif     }

ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif   }

InBlock.gif   
return singleFactory;
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立Factory类实例
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Factory类实例</returns>

InBlock.gif  public AbstractDbFactory CreateInstance()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   AbstractDbFactory abstractDbFactory 
= null;
InBlock.gif   
switch(ConfigurationSettings.AppSettings["DatabaseType"].ToLower())
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
case "sqlserver":
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     abstractDbFactory 
= new SqlFactory();
InBlock.gif     
break;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
case "oledb":
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     abstractDbFactory 
= new OleDbFactory();
InBlock.gif     
break;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
case "odbc":
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     abstractDbFactory 
= new OdbcFactory();
InBlock.gif     
break;
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif   }
   
InBlock.gif   
return abstractDbFactory;
ExpandedSubBlockEnd.gif  }

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif

以下3个类分别是Factory针对SqlServer专用连接、OleDb连接和Odbc连接时的具体实现:
(3)SqlFactory.cs
None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.Data.SqlClient;
None.gif
using  System.Configuration;
None.gif
None.gif
namespace  DbService
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// 针对SqlServer专用连接的工厂
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public class SqlFactory : AbstractDbFactory
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 构造函数
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  public SqlFactory()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立默认Connection对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  public IDbConnection CreateConnection()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new SqlConnection();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据连接字符串建立Connection对象
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strConn">连接字符串</param>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  public IDbConnection CreateConnection(string strConn)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new SqlConnection(strConn);
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立Command对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Command对象</returns>

InBlock.gif  public IDbCommand CreateCommand()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new SqlCommand();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立DataAdapter对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>DataAdapter对象</returns>

InBlock.gif  public IDbDataAdapter CreateDataAdapter()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new SqlDataAdapter();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Connection建立Transaction
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbConnection">Connection对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>Transaction对象</returns>

InBlock.gif  public IDbTransaction CreateTransaction(IDbConnection myDbConnection)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return myDbConnection.BeginTransaction();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Command建立DataReader
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbCommand">Command对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>DataReader对象</returns>

InBlock.gif  public IDataReader CreateDataReader(IDbCommand myDbCommand)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return myDbCommand.ExecuteReader();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 获得连接字符串
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>连接字符串</returns>

InBlock.gif  public string GetConnectionString()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
string strServer = ConfigurationSettings.AppSettings["SqlServerServer"];
InBlock.gif   
string strDatabase = ConfigurationSettings.AppSettings["SqlServerDatabase"];
InBlock.gif   
string strUid = ConfigurationSettings.AppSettings["SqlServerUid"];
InBlock.gif   
string strPwd = ConfigurationSettings.AppSettings["SqlServerPwd"];
InBlock.gif   
string strConnectionString = "Server = " + strServer + "; Database = " + strDatabase + "; Uid = " + strUid + "; Pwd = " + strPwd + ";";
InBlock.gif   
return strConnectionString;
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif

(4)OleDbFactory.cs
None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.Data.OleDb;
None.gif
using  System.Configuration;
None.gif
None.gif
namespace  DbService
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// 针对OleDb连接的工厂
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public class OleDbFactory : AbstractDbFactory
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 构造函数
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  public OleDbFactory()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立默认Connection对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  public IDbConnection CreateConnection()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OleDbConnection();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据连接字符串建立Connection对象
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strConn">连接字符串</param>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  public IDbConnection CreateConnection(string strConn)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OleDbConnection(strConn);
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立Command对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Command对象</returns>

InBlock.gif  public IDbCommand CreateCommand()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OleDbCommand();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立DataAdapter对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>DataAdapter对象</returns>
InBlock.gif  public IDbDataAdapter CreateDataAdapter()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OleDbDataAdapter();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Connection建立Transaction
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbConnection">Connection对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>Transaction对象</returns>

InBlock.gif  public IDbTransaction CreateTransaction(IDbConnection myDbConnection)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return myDbConnection.BeginTransaction();   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Command建立DataReader
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbCommand">Command对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>DataReader对象</returns>

InBlock.gif  public IDataReader CreateDataReader(IDbCommand myDbCommand)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return myDbCommand.ExecuteReader();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 获得连接字符串
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>连接字符串</returns>

InBlock.gif  public string GetConnectionString()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
string strProvider = ConfigurationSettings.AppSettings["OleDbProvider"];
InBlock.gif   
string strDataSource = ConfigurationSettings.AppSettings["OleDbDataSource"];
InBlock.gif   
string strConnectionString = "Provider = " + strProvider + ";Data Source = " + strDataSource + ";";
InBlock.gif   
return strConnectionString;
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif

(5)OdbcFactory.cs
None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.Data.Odbc;
None.gif
using  System.Configuration;
None.gif
None.gif
namespace  DbService
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// 针对Odbc连接的工厂
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public class OdbcFactory : AbstractDbFactory
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 构造函数
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  public OdbcFactory()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立默认Connection对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  public IDbConnection CreateConnection()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OdbcConnection();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据连接字符串建立Connection对象
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strConn">连接字符串</param>
ExpandedSubBlockEnd.gif  
/// <returns>Connection对象</returns>

InBlock.gif  public IDbConnection CreateConnection(string strConn)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OdbcConnection(strConn);
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立Command对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>Command对象</returns>

InBlock.gif  public IDbCommand CreateCommand()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OdbcCommand();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 建立DataAdapter对象
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns>DataAdapter对象</returns>

InBlock.gif  public IDbDataAdapter CreateDataAdapter()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return new OdbcDataAdapter();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Connection建立Transaction
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbConnection">Connection对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>Transaction对象</returns>

InBlock.gif  public IDbTransaction CreateTransaction(IDbConnection myDbConnection)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return myDbConnection.BeginTransaction();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 根据Command建立DataReader
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="myDbCommand">Command对象</param>
ExpandedSubBlockEnd.gif  
/// <returns>DataReader对象</returns>

InBlock.gif  public IDataReader CreateDataReader(IDbCommand myDbCommand)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
return myDbCommand.ExecuteReader();
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 获得连接字符串
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <returns></returns>

InBlock.gif  public string GetConnectionString()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   
string strDriver = ConfigurationSettings.AppSettings["OdbcDriver"];
InBlock.gif   
string strDBQ = ConfigurationSettings.AppSettings["OdbcDBQ"];
InBlock.gif   
string strConnectionString = "Driver={" + strDriver + "}; DBQ=" + strDBQ + ";";
InBlock.gif   
return strConnectionString;   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif

以下是在应用时真正要调用到的类:
(6)DbAccess.cs
None.gif using  System;
None.gif
using  System.Data;
None.gif
None.gif
namespace  DbService
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif 
/**//// <summary>
InBlock.gif 
/// DbAccess类,即进行数据库访问时需要调用的类
ExpandedSubBlockEnd.gif 
/// </summary>

InBlock.gif public sealed class DbAccess
ExpandedSubBlockStart.gifContractedSubBlock.gif 
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// DbAccess构造函数
ExpandedSubBlockEnd.gif  
/// </summary>

InBlock.gif  private DbAccess()
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 无条件查询操作,即查询表中所有记录
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strTableName">表名</param>
InBlock.gif  
/// <param name="strColumn">列名组</param>
ExpandedSubBlockEnd.gif  
/// <returns>无条件查询结果</returns>

InBlock.gif  public static DataSet SelectAll(string strTableName, string[] strColumn)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   DataSet ds 
= new DataSet();
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   IDbDataAdapter concreteDbAdapter 
= abstractDbFactory.CreateDataAdapter();
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "SELECT ";
InBlock.gif    
for(int i = 0; i < strColumn.Length - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     strSql 
+= (strColumn[i] + "");
ExpandedSubBlockEnd.gif    }

InBlock.gif    strSql 
+= (strColumn[strColumn.Length - 1+ " FROM " + strTableName);
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbAdapter.SelectCommand 
= concreteDbCommand;    
InBlock.gif    concreteDbAdapter.Fill(ds);
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    ds.Clear();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }
  
InBlock.gif   
return ds;
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 条件查询操作
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strTableName">表名</param>
InBlock.gif  
/// <param name="strColumn">列名组</param>
InBlock.gif  
/// <param name="strCondition">条件</param>
ExpandedSubBlockEnd.gif  
/// <returns>条件查询结果</returns>

InBlock.gif  public static DataSet Select(string strTableName, string[] strColumn, string strCondition)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   DataSet ds 
= new DataSet();
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   IDbDataAdapter concreteDbAdapter 
= abstractDbFactory.CreateDataAdapter();
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "SELECT ";
InBlock.gif    
for(int i = 0; i < strColumn.Length - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     strSql 
+= (strColumn[i] + "");
ExpandedSubBlockEnd.gif    }

InBlock.gif    strSql 
+= (strColumn[strColumn.Length - 1+ " FROM " + strTableName + " WHERE " + strCondition);
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbAdapter.SelectCommand 
= concreteDbCommand;    
InBlock.gif    concreteDbAdapter.Fill(ds);
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    ds.Clear();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
return ds;
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 单条记录的插入操作
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strTableName">表名</param>
InBlock.gif  
/// <param name="strColumn">列名组</param>
ExpandedSubBlockEnd.gif  
/// <param name="strValue">值组</param>

InBlock.gif  public static void Insert(string strTableName, string[] strColumn, object[] strValue)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();   
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "INSERT INTO " + strTableName + " (";
InBlock.gif    
for(int i = 0; i < strColumn.Length - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     strSql 
+= (strColumn[i] + "");
ExpandedSubBlockEnd.gif    }

InBlock.gif    strSql 
+= (strColumn[strColumn.Length - 1+ ") VALUES ('");
InBlock.gif    
for(int i = 0; i < strValue.Length - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     strSql 
+= (strValue[i] + "', '");
ExpandedSubBlockEnd.gif    }

InBlock.gif    strSql 
+= (strValue[strValue.Length - 1+ "')");
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbCommand.ExecuteNonQuery();
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }
   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 批量记录的插入操作,即可一次向多张表中插入不同的批量记录
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <param name="ds">批量记录组成的DataSet,DataSet中的各个DataTable名为表名,各DataTable中的DataColumn名为列名</param>

InBlock.gif  public static void InsertSet(ref DataSet ds)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();   
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
foreach(DataTable dt in ds.Tables)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     
foreach(DataRow dr in dt.Rows)
ExpandedSubBlockStart.gifContractedSubBlock.gif     
dot.gif{
InBlock.gif      
string strSql = "INSERT INTO " + dt.TableName + " (";
InBlock.gif      
for(int i = 0; i < dt.Columns.Count - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif      
dot.gif{
InBlock.gif       strSql 
+= (dt.Columns[i].Caption + "");
ExpandedSubBlockEnd.gif      }

InBlock.gif      strSql 
+= (dt.Columns[dt.Columns.Count - 1].Caption + ") VALUES ('");
InBlock.gif      
for(int i = 0; i < dt.Columns.Count - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif      
dot.gif{
InBlock.gif       strSql 
+= (dr[i] + "', '");
ExpandedSubBlockEnd.gif      }

InBlock.gif      strSql 
+= (dr[dt.Columns.Count - 1+ "')");
InBlock.gif      concreteDbCommand.CommandText 
= strSql;
InBlock.gif      concreteDbCommand.ExecuteNonQuery();
ExpandedSubBlockEnd.gif     }

ExpandedSubBlockEnd.gif    }

InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif
InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }
   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 无条件删除操作,即删除表中所有记录
InBlock.gif  
/// </summary>
ExpandedSubBlockEnd.gif  
/// <param name="strTableName">表名</param>

InBlock.gif  public static void DeleteAll(string strTableName)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "DELETE FROM " + strTableName;
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbCommand.ExecuteNonQuery();
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }
   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 条件删除操作
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strTableName">表名</param>
ExpandedSubBlockEnd.gif  
/// <param name="strCondition">条件</param>

InBlock.gif  public static void Delete(string strTableName, string strCondition)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "DELETE FROM " + strTableName + " WHERE " + strCondition;
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbCommand.ExecuteNonQuery();
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }
   
ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 无条件更新操作,即更新表中所有记录
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strTableName">表名</param>
InBlock.gif  
/// <param name="strColumn">列名组</param>
ExpandedSubBlockEnd.gif  
/// <param name="strValue">值组</param>

InBlock.gif  public static void UpdateAll(string strTableName, string[] strColumn, object[] strValue)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();   
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "UPDATE " + strTableName + " SET ";
InBlock.gif    
for(int i = 0; i < strColumn.Length - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     strSql 
+= (strColumn[i] + " = '" + strValue[i] + "', ");
ExpandedSubBlockEnd.gif    }

InBlock.gif    strSql 
+= (strColumn[strColumn.Length - 1+ " = '" + strValue[strValue.Length - 1+ "");
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbCommand.ExecuteNonQuery();
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }

ExpandedSubBlockEnd.gif  }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif  
/**//// <summary>
InBlock.gif  
/// 条件更新操作
InBlock.gif  
/// </summary>
InBlock.gif  
/// <param name="strTableName">表名</param>
InBlock.gif  
/// <param name="strColumn">列名组</param>
InBlock.gif  
/// <param name="strValue">值组</param>
ExpandedSubBlockEnd.gif  
/// <param name="strCondition">条件</param>

InBlock.gif  public static void Update(string strTableName, string[] strColumn, object[] strValue, string strCondition)
ExpandedSubBlockStart.gifContractedSubBlock.gif  
dot.gif{
InBlock.gif   Factory factory 
= Factory.GetInstance();
InBlock.gif   AbstractDbFactory abstractDbFactory 
= factory.CreateInstance();   
InBlock.gif   IDbConnection concreteDbConn 
= abstractDbFactory.CreateConnection();
InBlock.gif   concreteDbConn.ConnectionString 
= abstractDbFactory.GetConnectionString();
InBlock.gif   concreteDbConn.Open();
InBlock.gif   IDbCommand concreteDbCommand 
= abstractDbFactory.CreateCommand();
InBlock.gif   IDbTransaction concreteDbTrans 
= abstractDbFactory.CreateTransaction(concreteDbConn);
InBlock.gif   concreteDbCommand.Connection 
= concreteDbConn;
InBlock.gif   concreteDbCommand.Transaction 
= concreteDbTrans;
InBlock.gif   
try
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
string strSql = "UPDATE " + strTableName + " SET ";
InBlock.gif    
for(int i = 0; i < strColumn.Length - 1; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     strSql 
+= (strColumn[i] + " = '" + strValue[i] + "', ");
ExpandedSubBlockEnd.gif    }

InBlock.gif    strSql 
+= (strColumn[strColumn.Length - 1+ " = '" + strValue[strValue.Length - 1+ "" + " WHERE " + strCondition);
InBlock.gif    concreteDbCommand.CommandText 
= strSql;
InBlock.gif    concreteDbCommand.ExecuteNonQuery();
InBlock.gif    concreteDbTrans.Commit();
ExpandedSubBlockEnd.gif   }

InBlock.gif   
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbTrans.Rollback();
InBlock.gif    
throw;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
finally
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    concreteDbConn.Close();
ExpandedSubBlockEnd.gif   }

ExpandedSubBlockEnd.gif  }

ExpandedSubBlockEnd.gif }

ExpandedBlockEnd.gif}

None.gif
None.gif

最后一步,在Web.config中的根结点configuration下增加一些关于数据库连接字符串的变量:

None.gif < appSettings >
None.gif 
None.gif 
< add key = " DatabaseType "  value = " SqlServer "   />
None.gif 
None.gif 
< add key = " SqlServerServer "  value = " Ricky "   />
None.gif 
< add key = " SqlServerDatabase "  value = " test "   />
None.gif 
< add key = " SqlServerUid "  value = " sa "   />
None.gif 
< add key = " SqlServerPwd "  value = " henhaoba "   />
None.gif 
None.gif 
< add key = " OleDbProvider "  value = " Microsoft.jet.oledb.4.0 "   />
None.gif 
< add key = " OleDbDataSource "  value = " D:\test.mdb "   />
None.gif 
None.gif 
< add key = " OdbcDriver "  value = " Microsoft Access Driver (*.mdb) "   />
None.gif 
< add key = " OdbcDBQ "  value = " d:\test.mdb "   />
None.gif      
None.gif
</ appSettings >
None.gif

     现在一切OK,大家可以通过改变Web.config中的变量来使用不同的数据库连接方式(SqlServer专用连接、OleDb连接和Odbc连接)连接不同的数据库,同时整个使用仍通过DbAccess,不受任何影响。欢迎大家批评指正:)

转载于:https://www.cnblogs.com/silva/archive/2005/07/28/201724.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值