zoukankan      html  css  js  c++  java
  • 一个存储过程,多个select语句,形成多个表读取数据

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


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

    sql
    ALTER PROCEDURE [dbo].[novel_default]
    AS
        
    select top 2 * from novel_commend where mark=1
        
    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
        
    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
        
    select topicid,title,amount into #order_day from novel_order where datediff(daydateadd(day-1getdate()), times)>=0
        
    select top 19 topicid,title,sum(amount) as amount from #order_day group by topicid,title order by sum(amount) desc
        
    select topicid,title,amount into #order_week from novel_order  where datediff(daydateadd(day-7getdate()), times)>=0
        
    select top 19 topicid,title,sum(amount) as amount from #order_week group by topicid,title order by sum(amount) desc
        
    select top 20  topicid,title,hits from novel_topic order by hits desc
        
    select top 16 topicid,title from novel_commend where mark=0 order by commendid desc
        
    select top 16 topicid,title from novel_topic order by commend desc
        
    select top 16 topicid,title from novel_topic where hidden=0 order by addtime desc

  • 相关阅读:
    POJ 1251 Jungle Roads
    1111 Online Map (30 分)
    1122 Hamiltonian Cycle (25 分)
    POJ 2560 Freckles
    1087 All Roads Lead to Rome (30 分)
    1072 Gas Station (30 分)
    1018 Public Bike Management (30 分)
    1030 Travel Plan (30 分)
    22. bootstrap组件#巨幕和旋转图标
    3. Spring配置文件
  • 原文地址:https://www.cnblogs.com/zwl12549/p/814138.html
Copyright © 2011-2022 走看看