欢迎光临
我们一直在努力

建站超值云服务器,限时71元/月

  /// <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;
   
  }
  

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 »
分享到: 更多 (0)

相关推荐

  • 暂无文章