一个存储过程,多个select语句,形成多个表读取数据

None.gif      public   static  DataSet SqlNormal_( string  storename)
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        DataSet dataset 
= new DataSet();
InBlock.gif        SqlConnection SqlConn 
= new SqlConnection(connection);
InBlock.gif        SqlConn.Open();
InBlock.gif        SqlCommand comm 
= new SqlCommand(storename, SqlConn);
InBlock.gif        comm.CommandType 
= System.Data.CommandType.StoredProcedure;
InBlock.gif        SqlDataAdapter data 
= new SqlDataAdapter(comm);
InBlock.gif        data.Fill(dataset);
InBlock.gif        data.Dispose();
InBlock.gif        comm.Dispose();
InBlock.gif        SqlConn.Close();
InBlock.gif        
return dataset;
ExpandedBlockEnd.gif    }

None.gif
None.gif    
protected   void  Page_Load( object  sender, EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        DataSet dataset 
= SqlStore.SqlNormal_("novel_default");
InBlock.gif        
this.List_Very.DataSource = dataset.Tables[0];
InBlock.gif        
this.List_Very.DataBind();
InBlock.gif        
this.List_News.DataSource = dataset.Tables[1];
InBlock.gif        
this.List_News.DataBind();
InBlock.gif        
this.List_Update.DataSource = dataset.Tables[2];
InBlock.gif        
this.List_Update.DataBind();
InBlock.gif        
this.List_Day.DataSource = dataset.Tables[22];
InBlock.gif        
this.List_Day.DataBind();
InBlock.gif        
this.List_Week.DataSource = dataset.Tables[4];
InBlock.gif        
this.List_Week.DataBind();
InBlock.gif        
this.List_All.DataSource = dataset.Tables[5];
InBlock.gif        
this.List_All.DataBind();
InBlock.gif        
this.List_Commend1.DataSource = dataset.Tables[6];
InBlock.gif        
this.List_Commend1.DataBind();
InBlock.gif        
this.List_Commend2.DataSource = dataset.Tables[7];
InBlock.gif        
this.List_Commend2.DataBind();
InBlock.gif        
this.List_NewsBook.DataSource = dataset.Tables[8];
InBlock.gif        
this.List_NewsBook.DataBind();
ExpandedBlockEnd.gif    }

sql
None.gif ALTER   PROCEDURE   [ dbo ] . [ novel_default ]
None.gif
AS
None.gif    
select   top   2   *   from  novel_commend  where  mark = 1
None.gif    
select   top   6   [ name ] ,topicid,title,pic,intro  from  novel_topic,novel_board  where  pic <> ''   and  novel_topic.boardid = novel_board.boardid  and  hidden = 0   order   by  topicid  desc
None.gif    
select   top   40   [ name ] ,novel_topic.topicid  as  topicid,title,newchapter,author,updatetime  from  novel_topic,novel_board  where  novel_topic.boardid = novel_board.boardid  and  hidden = 0   order   by  updatetime  desc
None.gif    
select  topicid,title,amount  into  #order_day  from  novel_order  where   datediff ( day dateadd ( day - 1 getdate ()), times) >= 0
None.gif    
select   top   19  topicid,title, sum (amount)  as  amount  from  #order_day  group   by  topicid,title  order   by   sum (amount)  desc
None.gif    
select  topicid,title,amount  into  #order_week  from  novel_order   where   datediff ( day dateadd ( day - 7 getdate ()), times) >= 0
None.gif    
select   top   19  topicid,title, sum (amount)  as  amount  from  #order_week  group   by  topicid,title  order   by   sum (amount)  desc
None.gif    
select   top   20   topicid,title,hits  from  novel_topic  order   by  hits  desc
None.gif    
select   top   16  topicid,title  from  novel_commend  where  mark = 0   order   by  commendid  desc
None.gif    
select   top   16  topicid,title  from  novel_topic  order   by  commend  desc
None.gif    
select   top   16  topicid,title  from  novel_topic  where  hidden = 0   order   by  addtime  desc

转载于:https://www.cnblogs.com/zwl12549/archive/2007/07/11/814138.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值