// sql语句
public DataTable ExecuteTable(string sql)
{
using IDbConnection iDbConnection = DbConnection;
DataTable table = new DataTable();
var reader = iDbConnection.ExecuteReader(sql);
table.Load(reader);
return table;
}
//执行存储过程,返回DT
public DataTable ExecuteTable(string sql,object param, CommandType commandType)
{
using IDbConnection iDbConnection = DbConnection;
DataTable table = new DataTable();
var reader = iDbConnection.ExecuteReader(sql,param,null,null,commandType);
table.Load(reader);
return table;
}
//执行存储过程,返回DS
public DataSet ExecuteSet(string sql, object param, CommandType commandType)
{
using IDbConnection iDbConnection = DbConnection;
var reader = iDbConnection.ExecuteReader(sql, param, null, null, commandType);
DataSet ds = new DataSet();
int i = 0;
while (!reader.IsClosed)
{
ds.Tables.Add("Table" + (i + 1));
ds.EnforceConstraints = false;
ds.Tables[i].Load(reader);
i++;
}
return ds;
}
//返回多结构集
public virtual SqlMapper.GridReader QueryMultiple(string strSql)
{
using IDbConnection iDbConnection = DbConnection;
iDbConnection.Open();
return iDbConnection.QueryMultiple(strSql);
}