2.最近看了LTP的架构及Microsoft的PetShop.
3.目前决定对自己类库作改进。
其中DB核心代码:
DBOperator.cs(abstract)
using
System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.OracleClient;
namespace XPC.DB
{
/**//// <summary>
/// 抽象数据库操作类。
/// 类编码:QQDB001
/// </summary>
/// <remark>抽象数据库操作类,类编码:QQDB001</remark>
public abstract class DBOperator
{
方法#region 方法
方法: Connection()#region 方法: Connection()
/**//// <summary>
/// 得到数据库连接
/// 函数编码:001
/// </summary>
/// <returns>返回数据库连接IDbConnection</returns>
/// <remark>得到数据库连接,函数编码:001</remark>
public abstract IDbConnection Connection();
#endregion
方法: Open()#region 方法: Open()
/**//// <summary>
/// 打开数据库连接,函数编码:002
/// </summary>
/// <returns>是否成功</returns>
/// <remark>打开数据库连接,函数编码:002</remark>
public abstract bool Open();
#endregion
方法: Close()#region 方法: Close()
/**//// <summary>
/// 关闭数据库连接,函数编码:003
/// </summary>
/// <returns>是否成功</returns>
/// <remark>关闭数据库连接,函数编码:003</remark>
public abstract bool Close();
#endregion
方法: BeginTrans()#region 方法: BeginTrans()
/**//// <summary>
/// 开始一个事务,函数编码:004
/// </summary>
/// <returns>是否成功</returns>
/// <remark>开始一个事务,函数编码:004</remark>
public abstract bool BeginTrans();
#endregion
方法: CommitTrans()#region 方法: CommitTrans()
/**//// <summary>
/// 执行事务,函数编码:005
/// </summary>
/// <returns>是否成功</returns>
/// <remark>执行事务,函数编码:005</remark>
public abstract bool CommitTrans();
#endregion
方法: RollbackTrans()#region 方法: RollbackTrans()
/**//// <summary>
/// 回滚一个事务,函数编码:006
/// </summary>
/// <returns>是否成功</returns>
/// <remark>回滚一个事务,函数编码:006</remark>
public abstract bool RollbackTrans();
#endregion
方法: Execute(string strSql,)#region 方法: Execute(string strSql,)
/**//// <summary>
/// 执行SQL语句,返回影响行数。函数编码:007
/// </summary>
/// <param name="strSql">Sql语句</param>
/// <returns>返回int,影响的行数</returns>
/// <remark>执行SQL语句,返回影响行数。函数编码:007</remark>
public abstract int Execute(string strSql);
#endregion
方法: Execute(string strSql,out string strCurrentID,)#region 方法: Execute(string strSql,out string strCurrentID,)
/**//// <summary>
/// 执行SQL语句,out当前ID。函数编码:008
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <param name="strCurrentID">输出当前ID</param>
/// <returns>无返回</returns>
/// <remark>执行SQL语句,out当前ID。函数编码:008</remark>
public abstract void Execute(string strSql,out string strCurrentID);
#endregion
方法: GetScalar(string strSql)#region 方法: GetScalar(string strSql)
/**//// <summary>
/// 执行SQL语句返回第一行第一列的值。函数编码:009
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>string类型每一行第一列</returns>
/// <remark>执行SQL语句返回第一行第一列的值。函数编码:009</remark>
public abstract string GetScalar(string strSql);
#endregion
方法: GetDataTable(string strSql)#region 方法: GetDataTable(string strSql)
/**//// <summary>
/// 执行SQL语句返回DataTable。函数编码:010
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>一个记录集datatable</returns>
/// <remark>执行SQL语句返回DataTable。函数编码:010</remark>
public abstract DataTable GetDataTable(string strSql);
#endregion
方法: GetDataSet(string strSql)#region 方法: GetDataSet(string strSql)
/**//// <summary>
/// 执行SQL语句返回DataSet。函数编码:011
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回数据集DataSet</returns>
/// <remark>执行SQL语句返回DataSet。函数编码:011</remark>
public abstract DataSet GetDataSet(string strSql);
#endregion
方法: GetSqlDataReader(string strSql)#region 方法: GetSqlDataReader(string strSql)
/**//// <summary>
/// 执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭,函数编码:012
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回SqlDataReader</returns>
/// <remark>执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭。函数编码:012</remark>
public abstract SqlDataReader GetSqlDataReader(string strSql);
#endregion
方法: GetSqlDataReader(string strSql,SqlConnection conn)#region 方法: GetSqlDataReader(string strSql,SqlConnection conn)
/**//// <summary>
/// 执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭,函数编码:012
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <param name="conn">Sql连接</param>
/// <returns>返回SqlDataReader</returns>
/// <remark>执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭。函数编码:012</remark>
public abstract SqlDataReader GetSqlDataReader(string strSql, out SqlConnection sqlconn);
#endregion
方法: GetOleDBDataReader(string strSql,)#region 方法: GetOleDBDataReader(string strSql,)
/**//// <summary>
/// 执行SQL语句返回OleDBDataReader。重要:其中的Connection没有关闭,函数编码:013
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回OleDBDataReader</returns>
/// <remark>执行SQL语句返回OleDBDataReader。重要:其中的Connection没有关闭,函数编码:013</remark>
public abstract OleDbDataReader GetOleDBDataReader(string strSql);
#endregion
方法: GetOracleDataReader(string strSql,)#region 方法: GetOracleDataReader(string strSql,)
/**//// <summary>
/// 执行SQL语句返回OracleDataReader。重要:其中的Connection没有关闭,函数编码:014
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回OracleDataReader</returns>
/// <remark>执行SQL语句返回OracleDataReader。重要:其中的Connection没有关闭,函数编码:014</remark>
public abstract OracleDataReader GetOracleDataReader(string strSql);
#endregion
方法: ExecuteProc(string strProcedureName,)#region 方法: ExecuteProc(string strProcedureName,)
/**//// <summary>
/// 执行存储过程,返回影响行数。函数编码:015
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <returns>返回int类型的影响行数</returns>
/// <remark>执行存储过程,返回影响行数函数编码:015</remark>
public abstract int ExecuteProc(string strProcedureName);
#endregion
方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,)#region 方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,)
/**//// <summary>
/// 执行存储过程,返回影响行数。函数编码:016
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <returns>返回int类型的影响行数</returns>
/// <remark>执行存储过程,返回影响行数,函数编码:016</remark>
public abstract int ExecuteProc(string strProcedureName,IDataParameter [] arrParameterArray);
#endregion
方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,out string strOutValue)#region 方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,out string strOutValue)
/**//// <summary>
/// 执行存储过程,返回影响行数。其中out一个参数的值,此参数可以为不是input的其它类型
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <param name="strOutValue">out的参数,把存在过程的参数中类型不是Input的最后一个参数的值返回</param>
/// <returns>返回影响行数</returns>
/// <remark>执行存储过程,返回影响行数</remark>
public abstract int ExecuteProc(string strProcedureName, IDataParameter[] arrParameterArray, out string strOutValue);
#endregion
方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray, out string strCurrentID)#region 方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray, out string strCurrentID)
/**//// <summary>
/// 执行存储过程,返回影响行数。函数编码:016
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <param name="strCurrentID">out 当前ID</param>
/// <returns>返回int类型的影响行数</returns>
/// <remark>执行存储过程,返回影响行数,函数编码:016</remark>
public abstract int ExecuteProc(string strProcedureName, IDataParameter[] arrParameterArray, out int strCurrentID);
#endregion
public abstract string GetProcScalar(string strProcedureName);
public abstract string GetProcScalar(string strProcedureName, IDataParameter[] arrParameterArray);
方法: GetProcDataTable(string strProcedureName,)#region 方法: GetProcDataTable(string strProcedureName,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:017
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:017</remark>
public abstract DataTable GetProcDataTable(string strProcedureName);
#endregion
方法: GetProcDataTable(string strProcedureName,int intTableIndex,)#region 方法: GetProcDataTable(string strProcedureName,int intTableIndex,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:018
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="intTableIndex">表索引号</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:018</remark>
public abstract DataTable GetProcDataTable(string strProcedureName,int intTableIndex);
#endregion
方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,)#region 方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:019
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:019</remark>
public abstract DataTable GetProcDataTable(string strProcedureName,IDataParameter [] arrParameterArray);
#endregion
方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,int intTableIndex,)#region 方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,int intTableIndex,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:019
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <param name="intTableIndex">表索引号</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:019</remark>
public abstract DataTable GetProcDataTable(string strProcedureName,IDataParameter [] arrParameterArray,int intTableIndex);
#endregion
方法: GetProcDataSet(string strProcedureName,)#region 方法: GetProcDataSet(string strProcedureName,)
/**//// <summary>
/// 执行存储过程,返回DataSet。c函数编码:020
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <returns>返回DataSet</returns>
/// <remark>执行存储过程,返回DataSet,函数编码:020</remark>
public abstract DataSet GetProcDataSet(string strProcedureName);
#endregion
方法: GetProcDataSet(string strProcedureName,idataparameter [] arrParameterArray,)#region 方法: GetProcDataSet(string strProcedureName,idataparameter [] arrParameterArray,)
/**//// <summary>
/// 执行存储过程,返回DataSet。,函数编码:021
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <returns>返回DataSet</returns>
/// <remark>执行存储过程,返回DataSet,函数编码:021</remark>
public abstract DataSet GetProcDataSet(string strProcedureName,IDataParameter [] arrParameterArray);
#endregion
/批量执行SQL语句#region /////批量执行SQL语句
/**//// <summary>
/// 批量执行SQL语句
/// </summary>
/// <param name="strSqls">SQL语句数组</param>
/// <returns>true成功,false失败</returns>
public abstract bool BatchExecSql(string[] strSqls);
#endregion
/**//// <summary>
/// 清理释放
/// </summary>
public abstract void Dispose();
#endregion
}
}
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.OracleClient;
namespace XPC.DB
{
/**//// <summary>
/// 抽象数据库操作类。
/// 类编码:QQDB001
/// </summary>
/// <remark>抽象数据库操作类,类编码:QQDB001</remark>
public abstract class DBOperator
{
方法#region 方法
方法: Connection()#region 方法: Connection()
/**//// <summary>
/// 得到数据库连接
/// 函数编码:001
/// </summary>
/// <returns>返回数据库连接IDbConnection</returns>
/// <remark>得到数据库连接,函数编码:001</remark>
public abstract IDbConnection Connection();
#endregion
方法: Open()#region 方法: Open()
/**//// <summary>
/// 打开数据库连接,函数编码:002
/// </summary>
/// <returns>是否成功</returns>
/// <remark>打开数据库连接,函数编码:002</remark>
public abstract bool Open();
#endregion
方法: Close()#region 方法: Close()
/**//// <summary>
/// 关闭数据库连接,函数编码:003
/// </summary>
/// <returns>是否成功</returns>
/// <remark>关闭数据库连接,函数编码:003</remark>
public abstract bool Close();
#endregion
方法: BeginTrans()#region 方法: BeginTrans()
/**//// <summary>
/// 开始一个事务,函数编码:004
/// </summary>
/// <returns>是否成功</returns>
/// <remark>开始一个事务,函数编码:004</remark>
public abstract bool BeginTrans();
#endregion
方法: CommitTrans()#region 方法: CommitTrans()
/**//// <summary>
/// 执行事务,函数编码:005
/// </summary>
/// <returns>是否成功</returns>
/// <remark>执行事务,函数编码:005</remark>
public abstract bool CommitTrans();
#endregion
方法: RollbackTrans()#region 方法: RollbackTrans()
/**//// <summary>
/// 回滚一个事务,函数编码:006
/// </summary>
/// <returns>是否成功</returns>
/// <remark>回滚一个事务,函数编码:006</remark>
public abstract bool RollbackTrans();
#endregion
方法: Execute(string strSql,)#region 方法: Execute(string strSql,)
/**//// <summary>
/// 执行SQL语句,返回影响行数。函数编码:007
/// </summary>
/// <param name="strSql">Sql语句</param>
/// <returns>返回int,影响的行数</returns>
/// <remark>执行SQL语句,返回影响行数。函数编码:007</remark>
public abstract int Execute(string strSql);
#endregion
方法: Execute(string strSql,out string strCurrentID,)#region 方法: Execute(string strSql,out string strCurrentID,)
/**//// <summary>
/// 执行SQL语句,out当前ID。函数编码:008
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <param name="strCurrentID">输出当前ID</param>
/// <returns>无返回</returns>
/// <remark>执行SQL语句,out当前ID。函数编码:008</remark>
public abstract void Execute(string strSql,out string strCurrentID);
#endregion
方法: GetScalar(string strSql)#region 方法: GetScalar(string strSql)
/**//// <summary>
/// 执行SQL语句返回第一行第一列的值。函数编码:009
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>string类型每一行第一列</returns>
/// <remark>执行SQL语句返回第一行第一列的值。函数编码:009</remark>
public abstract string GetScalar(string strSql);
#endregion
方法: GetDataTable(string strSql)#region 方法: GetDataTable(string strSql)
/**//// <summary>
/// 执行SQL语句返回DataTable。函数编码:010
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>一个记录集datatable</returns>
/// <remark>执行SQL语句返回DataTable。函数编码:010</remark>
public abstract DataTable GetDataTable(string strSql);
#endregion
方法: GetDataSet(string strSql)#region 方法: GetDataSet(string strSql)
/**//// <summary>
/// 执行SQL语句返回DataSet。函数编码:011
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回数据集DataSet</returns>
/// <remark>执行SQL语句返回DataSet。函数编码:011</remark>
public abstract DataSet GetDataSet(string strSql);
#endregion
方法: GetSqlDataReader(string strSql)#region 方法: GetSqlDataReader(string strSql)
/**//// <summary>
/// 执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭,函数编码:012
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回SqlDataReader</returns>
/// <remark>执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭。函数编码:012</remark>
public abstract SqlDataReader GetSqlDataReader(string strSql);
#endregion
方法: GetSqlDataReader(string strSql,SqlConnection conn)#region 方法: GetSqlDataReader(string strSql,SqlConnection conn)
/**//// <summary>
/// 执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭,函数编码:012
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <param name="conn">Sql连接</param>
/// <returns>返回SqlDataReader</returns>
/// <remark>执行SQL语句返回SqlDataReader。重要:其中的Connection没有关闭。函数编码:012</remark>
public abstract SqlDataReader GetSqlDataReader(string strSql, out SqlConnection sqlconn);
#endregion
方法: GetOleDBDataReader(string strSql,)#region 方法: GetOleDBDataReader(string strSql,)
/**//// <summary>
/// 执行SQL语句返回OleDBDataReader。重要:其中的Connection没有关闭,函数编码:013
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回OleDBDataReader</returns>
/// <remark>执行SQL语句返回OleDBDataReader。重要:其中的Connection没有关闭,函数编码:013</remark>
public abstract OleDbDataReader GetOleDBDataReader(string strSql);
#endregion
方法: GetOracleDataReader(string strSql,)#region 方法: GetOracleDataReader(string strSql,)
/**//// <summary>
/// 执行SQL语句返回OracleDataReader。重要:其中的Connection没有关闭,函数编码:014
/// </summary>
/// <param name="strSql">SQL语句字符串</param>
/// <returns>返回OracleDataReader</returns>
/// <remark>执行SQL语句返回OracleDataReader。重要:其中的Connection没有关闭,函数编码:014</remark>
public abstract OracleDataReader GetOracleDataReader(string strSql);
#endregion
方法: ExecuteProc(string strProcedureName,)#region 方法: ExecuteProc(string strProcedureName,)
/**//// <summary>
/// 执行存储过程,返回影响行数。函数编码:015
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <returns>返回int类型的影响行数</returns>
/// <remark>执行存储过程,返回影响行数函数编码:015</remark>
public abstract int ExecuteProc(string strProcedureName);
#endregion
方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,)#region 方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,)
/**//// <summary>
/// 执行存储过程,返回影响行数。函数编码:016
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <returns>返回int类型的影响行数</returns>
/// <remark>执行存储过程,返回影响行数,函数编码:016</remark>
public abstract int ExecuteProc(string strProcedureName,IDataParameter [] arrParameterArray);
#endregion
方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,out string strOutValue)#region 方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray,out string strOutValue)
/**//// <summary>
/// 执行存储过程,返回影响行数。其中out一个参数的值,此参数可以为不是input的其它类型
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <param name="strOutValue">out的参数,把存在过程的参数中类型不是Input的最后一个参数的值返回</param>
/// <returns>返回影响行数</returns>
/// <remark>执行存储过程,返回影响行数</remark>
public abstract int ExecuteProc(string strProcedureName, IDataParameter[] arrParameterArray, out string strOutValue);
#endregion
方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray, out string strCurrentID)#region 方法: ExecuteProc(string strProcedureName,idataparameter [] arrParameterArray, out string strCurrentID)
/**//// <summary>
/// 执行存储过程,返回影响行数。函数编码:016
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <param name="strCurrentID">out 当前ID</param>
/// <returns>返回int类型的影响行数</returns>
/// <remark>执行存储过程,返回影响行数,函数编码:016</remark>
public abstract int ExecuteProc(string strProcedureName, IDataParameter[] arrParameterArray, out int strCurrentID);
#endregion
public abstract string GetProcScalar(string strProcedureName);
public abstract string GetProcScalar(string strProcedureName, IDataParameter[] arrParameterArray);
方法: GetProcDataTable(string strProcedureName,)#region 方法: GetProcDataTable(string strProcedureName,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:017
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:017</remark>
public abstract DataTable GetProcDataTable(string strProcedureName);
#endregion
方法: GetProcDataTable(string strProcedureName,int intTableIndex,)#region 方法: GetProcDataTable(string strProcedureName,int intTableIndex,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:018
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="intTableIndex">表索引号</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:018</remark>
public abstract DataTable GetProcDataTable(string strProcedureName,int intTableIndex);
#endregion
方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,)#region 方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:019
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:019</remark>
public abstract DataTable GetProcDataTable(string strProcedureName,IDataParameter [] arrParameterArray);
#endregion
方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,int intTableIndex,)#region 方法: GetProcDataTable(string strProcedureName,idataparameter [] arrParameterArray,int intTableIndex,)
/**//// <summary>
/// 执行存储过程,返回DataTable。函数编码:019
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <param name="intTableIndex">表索引号</param>
/// <returns>返回DataTable</returns>
/// <remark>执行存储过程,返回DataTable,函数编码:019</remark>
public abstract DataTable GetProcDataTable(string strProcedureName,IDataParameter [] arrParameterArray,int intTableIndex);
#endregion
方法: GetProcDataSet(string strProcedureName,)#region 方法: GetProcDataSet(string strProcedureName,)
/**//// <summary>
/// 执行存储过程,返回DataSet。c函数编码:020
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <returns>返回DataSet</returns>
/// <remark>执行存储过程,返回DataSet,函数编码:020</remark>
public abstract DataSet GetProcDataSet(string strProcedureName);
#endregion
方法: GetProcDataSet(string strProcedureName,idataparameter [] arrParameterArray,)#region 方法: GetProcDataSet(string strProcedureName,idataparameter [] arrParameterArray,)
/**//// <summary>
/// 执行存储过程,返回DataSet。,函数编码:021
/// </summary>
/// <param name="strProcedureName">存储过程名</param>
/// <param name="arrParameterArray">参数集合</param>
/// <returns>返回DataSet</returns>
/// <remark>执行存储过程,返回DataSet,函数编码:021</remark>
public abstract DataSet GetProcDataSet(string strProcedureName,IDataParameter [] arrParameterArray);
#endregion
/批量执行SQL语句#region /////批量执行SQL语句
/**//// <summary>
/// 批量执行SQL语句
/// </summary>
/// <param name="strSqls">SQL语句数组</param>
/// <returns>true成功,false失败</returns>
public abstract bool BatchExecSql(string[] strSqls);
#endregion
/**//// <summary>
/// 清理释放
/// </summary>
public abstract void Dispose();
#endregion
}
}
DBOperatorFactory.cs (DBFactory)
using
System;
using System.Collections.Generic;
using System.Text;
namespace XPC.DB
{
/**//// <summary>
/// 调用数据库操作类的工厂类 的摘要说明。
/// 选择那种数据库
/// </summary>
public class DBOperatorFactory
{
//读取配置中的数据库类型,连接字符串
private static readonly string C_strDBType = System.Configuration.ConfigurationSettings.AppSettings["DBType"];//Common.GetWebConfigValue("DBType").Trim();
private static readonly string C_strConnection = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];//Common.GetWebConfigValue("ConnectionString").Trim();
/**//// <summary>
/// 获取一个数据库操作对象
/// </summary>
/// <param name="strConnection">数据库连接字符串</param>
/// <returns>数据库操作对象</returns>
public static DBOperator GetDBOperator()
{
try
{
//string
switch (DBOperatorFactory.C_strDBType.ToUpper())
{
case "SQLSERVER":
return new SqlDBOperator(DBOperatorFactory.C_strConnection);
case "ORACLE":
return null;
case "OLEDB":
return null;
case "ODBC":
return null;
default:
return new SqlDBOperator(DBOperatorFactory.C_strConnection);
}
}
catch(Exception ex)
{
throw ex;
}
}
}
}
DB层,Common层,一些自行开发用户控件源码下载
using System.Collections.Generic;
using System.Text;
namespace XPC.DB
{
/**//// <summary>
/// 调用数据库操作类的工厂类 的摘要说明。
/// 选择那种数据库
/// </summary>
public class DBOperatorFactory
{
//读取配置中的数据库类型,连接字符串
private static readonly string C_strDBType = System.Configuration.ConfigurationSettings.AppSettings["DBType"];//Common.GetWebConfigValue("DBType").Trim();
private static readonly string C_strConnection = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];//Common.GetWebConfigValue("ConnectionString").Trim();
/**//// <summary>
/// 获取一个数据库操作对象
/// </summary>
/// <param name="strConnection">数据库连接字符串</param>
/// <returns>数据库操作对象</returns>
public static DBOperator GetDBOperator()
{
try
{
//string
switch (DBOperatorFactory.C_strDBType.ToUpper())
{
case "SQLSERVER":
return new SqlDBOperator(DBOperatorFactory.C_strConnection);
case "ORACLE":
return null;
case "OLEDB":
return null;
case "ODBC":
return null;
default:
return new SqlDBOperator(DBOperatorFactory.C_strConnection);
}
}
catch(Exception ex)
{
throw ex;
}
}
}
}
方案:
1.原有库保留,Pet的接口模式目前不适合,添加BLL.Util,此为基于DB层,为BLL所调用