Odbc、OleDb、Oracle、SqlServer通用数据访问支持存储过程(已上传源码)
详细情况下载源码:
接口定义如:
Code
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace Yuntop.DataProvider
{
/// <summary>
/// 提供对数据库的通访问接口
/// </summary>
public interface IDataProvider
{
/// <summary>
/// 执行 UPDATE、INSERT 和 DELETE 语句,返回值为该命令所影响的行数
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <returns>受影响的行</returns>
int ExecuteNonQuery(string connectionString, string sql, CommandType cmdType);
/// <summary>
/// 执行 UPDATE、INSERT 和 DELETE 语句,返回值为该命令所影响的行数
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <param name="parameter">参数数组</param>
/// <returns>受影响的行</returns>
int ExecuteNonQuery(string connectionString, string sql, CommandType cmdType, params IDataParameter[] parameter);
/// <summary>
/// 执行无返回的Sql事务
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句数组</param>
/// <param name="cmdType">Sql类型</param>
void ExecuteSqlTran(string connectionString, string[] sql, CommandType cmdType);
/// <summary>
/// 执行查询,并将查询返回的结果集中第一行的第一列作为 .NET Framework 数据类型返回。忽略额外的列或行
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <returns>结果中的第一行第一列</returns>
object ExecuteScalar(string connectionString, string sql, CommandType cmdType);
/// <summary>
/// 执行查询,并将查询返回的结果集中第一行的第一列作为 .NET Framework 数据类型返回。忽略额外的列或行
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <param name="parameter">参数数组</param>
/// <returns>结果中的第一行第一列</returns>
object ExecuteScalar(string connectionString, string sql, CommandType cmdType, params IDataParameter[] parameter);
/// <summary>
/// 返回只读的DataReader接口,使用后记得关闭
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <returns></returns>
IDataReader ExeciteReader(string connectionString, string sql, CommandType cmdType);
/// <summary>
/// 返回只读的DataReader接口,使用后记得关闭
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <param name="parameter">参数数组</param>
/// <returns></returns>
IDataReader ExeciteReader(string connectionString, string sql, CommandType cmdType, params IDataParameter[] parameter);
/// <summary>
/// 执行Sql语句并将结果以一个数据集返回
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <returns>返回DataSet</returns>
DataSet RetriveDataSet(string connectionString, string sql);
/// <summary>
/// 执行多条Sql语句并将结果以一个数据集返回
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <param name="parameter">参数数组</param>
/// <returns>返回DataTable</returns>
DataSet RetriveDataSet(string connectionString, string sql, CommandType cmdType, params IDataParameter[] parameter);
/// <summary>
/// 根据Sql语句返回指定表的构架信息,如:SELECT [Table].* FROM [Table]将返Table的构架信息
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="sql">Sql执行语句</param>
/// <param name="cmdType">Sql类型</param>
/// <returns>表的构架信息</returns>
DataTable GetSchemaTable(string connectionString, string sql, CommandType cmdType);
/// <summary>
/// 返回数据库构架信息
/// </summary>
/// <param name="connectionString">数据库连接字符串</param>
/// <param name="collectionName">要返回的构架名称,如:Tables</param>
/// <param name="restrictionValues">为请求的构架指定一组限制值</param>
/// <returns>指定的构架信息</returns>
DataTable GetSchema(string connectionString, string collectionName, string[] restrictionValues);
/// <summary>
/// 获取连接字符串
/// </summary>
/// <returns></returns>
string GetConnectionString();
/// <summary>
/// 设置连接字符串
/// </summary>
/// <param name="connectionString">连接字符串</param>
void SetConnectionString(string connString);
/// <summary>
/// 数据提供者Command的参数
/// </summary>
/// <returns></returns>
IDataParameter DataProviderParameter();
void Dispose();
}
}