源代码 /// <summary>
/// 执行一个查询操作,并且以System.Data.IDataReader()来返回结果集
/// </summary>
/// <returns>返回的System.Data.IDataReader</returns>
public System.Data.IDataReader ExecuteDataReader()
{
System.Data.IDataReader result=null;
this.Prepare();
try
{
result=this.m_command.ExecuteReader();
}
catch(Exception e)
{
throw new JoyBaseDBException(e.Message,e);
}
//this.m_Parameters.Clear();
return result;
}
/// <summary>
/// 执行一个查询操作,并且返回一个DataTable
/// </summary>
/// <returns>返回一个DataTable</returns>
public System.Data.DataTable ExecuteDataTable()
{
this.Prepare();
System.Data.DataTable result=new System.Data.DataTable();
//System.Data.Common.DbDataAdapter Adapter=null;
try
{
if(Provider.Type==DBType.SqlClient)
{
System.Data.SqlClient.SqlDataAdapter Adapter=new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)this.m_command);
//Adapter.SelectCommand=new System.Data.SqlClient.SqlCommand(,(System.Data.SqlClient.SqlConnection)Provider.getConn());//(System.Data.SqlClient.SqlCommand)this.m_command;
Adapter.Fill(result);
}
else
{
System.Data.OleDb.OleDbDataAdapter Adapter=new System.Data.OleDb.OleDbDataAdapter((System.Data.OleDb.OleDbCommand)this.m_command);
//Adapter.SelectCommand=(System.Data.OleDb.OleDbCommand)this.m_command;
Adapter.Fill(result);
}
}
catch(Exception e)
{
throw new JoyBaseDBException(e.Message,e);
}
//this.m_Parameters.Clear();
return result;
}
/// <summary>
/// 返回分页的DataSet页面
/// </summary>
/// <param name="p_TableName">DataSet中的表名</param>
/// <param name="p_CurrentPageIndex">需要返回的页面</param>
/// <returns></returns>
public System.Data.DataSet ExecuteDataSet(string p_TableName,int p_CurrentPageIndex)
{
System.Data.DataSet ds=this.ExecuteDataSet();
try
{
this.m_RecordCount=ds.Tables[0].Rows.Count;
//
ds.Clear();
ds.Dispose();
if(this.m_RecordCount%this.m_PageSize==0)
{
this.m_PageCount=this.m_RecordCount/this.m_PageSize;
}
else
{
this.m_PageCount=this.m_RecordCount/this.m_PageSize+1;
}
int StartCount=(p_CurrentPageIndex-1)*this.m_PageSize;
ds=this.ExecuteDataSet(p_TableName,StartCount,this.m_PageSize);
}
catch(Exception e)
{
string reason="(1)未设置PageSize变量或者将其设为不合理数值,而直接调用了分页方法\r\n;(2)检索的页号不存在或者溢出;\r\n";
throw new JoyBaseDBException(e.Message,reason);
}
//this.m_Parameters.Clear();
return ds;
}
/// <summary>
/// 执行一个查询操作,并且返回一个DataSet对象,能够执行分页操作
/// </summary>
/// <param name="p_StartRecord">起始的记录号,以0开始</param>
/// <param name="p_MaxRecords">返回的最多的记录号</param>
/// <param name="p_TableName">返回的DataSet中包含的表的名称</param>
/// <returns>返回一个DataSet对象</returns>
public System.Data.DataSet ExecuteDataSet(string p_TableName,int p_StartRecord,int p_MaxRecords)
{
this.Prepare();
System.Data.DataSet result=new System.Data.DataSet();
//System.Data.Common.DbDataAdapter Adapter=null;
try
{
if(Provider.Type==DBType.SqlClient)
{
System.Data.SqlClient.SqlDataAdapter Adapter=new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)this.m_command);
//Adapter.SelectCommand=new System.Data.SqlClient.SqlCommand("select * from orders",(System.Data.SqlClient.SqlConnection)Provider.getConn("DSN"));//(System.Data.SqlClient.SqlCommand)this.m_command;
Adapter.Fill(result,p_StartRecord,p_MaxRecords,p_TableName);
}
else
{
System.Data.OleDb.OleDbDataAdapter Adapter=new System.Data.OleDb.OleDbDataAdapter((System.Data.OleDb.OleDbCommand)this.m_command);
//Adapter.SelectCommand=(System.Data.OleDb.OleDbCommand)this.m_command;
Adapter.Fill(result,p_StartRecord,p_MaxRecords,p_TableName);
}
}
catch(Exception e)
{
throw new JoyBaseDBException(e.Message,e);
}
//this.m_Parameters.Clear();
return result;
}
/// <summary>
/// 执行查询操作,并且返回一个DataSet对象
/// </summary>
/// <param name="p_TableName">DataSet中包含的表的名称</param>
/// <returns>返回一个DataSet对象</returns>
public System.Data.DataSet ExecuteDataSet(string p_TableName)
{
this.Prepare();
System.Data.DataSet result=new System.Data.DataSet();
try
{
//System.Data.Common.DbDataAdapter Adapter=null;
if(Provider.Type==DBType.SqlClient)
{
System.Data.SqlClient.SqlDataAdapter Adapter=new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)this.m_command);
//Adapter.SelectCommand=new System.Data.SqlClient.SqlCommand("select * from orders",(System.Data.SqlClient.SqlConnection)Provider.getConn("DSN"));//(System.Data.SqlClient.SqlCommand)this.m_command;
Adapter.Fill(result,p_TableName);
}
else
{
System.Data.OleDb.OleDbDataAdapter Adapter=new System.Data.OleDb.OleDbDataAdapter((System.Data.OleDb.OleDbCommand)this.m_command);
//Adapter.SelectCommand=(System.Data.OleDb.OleDbCommand)this.m_command;
Adapter.Fill(result,p_TableName);
}
}
catch(Exception e)
{
throw new JoyBaseDBException(e.Message,e);
}
//this.m_Parameters.Clear();
return result;
}
/// <summary>
/// 执行查询操作,并且返回一个DataSet对象
/// </summary>
/// <returns>返回一个DataSet对象,并且其中的DataSet中的表名称为默认的“Table”</returns>
public System.Data.DataSet ExecuteDataSet()
{
this.Prepare();
System.Data.DataSet result=new System.Data.DataSet();
try
{
if(Provider.Type==DBType.SqlClient)
{
System.Data.SqlClient.SqlDataAdapter Adapter=new System.Data.SqlClient.SqlDataAdapter((System.Data.SqlClient.SqlCommand)this.m_command);
Adapter.Fill(result);
}
else
{
System.Data.OleDb.OleDbDataAdapter Adapter=new System.Data.OleDb.OleDbDataAdapter((System.Data.OleDb.OleDbCommand)this.m_command);
Adapter.Fill(result);
}
}
catch(Exception e)
{
throw new JoyBaseDBException(e.Message,e);
}
//this.m_Parameters.Clear();
return result;
}
com.joybase.DB.dll源代码(3)
80酷酷网 80kuku.com