• No.6(使用DataView对数据排序)


    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.SqlClient;
    
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string strCon = "Data Source=ahxh-02;Initial Catalog=PubBase;Integrated Security=True";
            SqlConnection connection = new SqlConnection(strCon);
            connection.Open();
    
    
            SqlCommand command = new SqlCommand("getinfo",connection);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
    
            DataTable dt = new DataTable("table1");
            adapter.Fill(dt);
    
            DataView dv = new DataView();
            dv.Table = dt;
            dv.Sort = "productId desc";
            dv.RowFilter = "productName ='黄山牌香烟'";
    
            this.GridView1.DataSource = dv;
            this.GridView1.DataBind();
    
    
        }
    }
    create database PubBase
    use PubBase
    
    create table Product
    (
        productId int primary key identity(1,1),
        productName varchar(20) 
    )
    
    insert into product values('黄山牌香烟')
    insert into product values('贵州牌香烟')
    insert into product values('云南牌香烟')
    insert into product values('金龙王牌香烟')
    insert into product values('小熊猫香烟')
    
    
    --存储过程1
    create proc GetProInfo
    
    as
      select * from Product
    
    exec GetProInfo
    
    --存储过程2
    create proc GetProInfo2
    (
      @id int
    )
    as
      select * from Product
      where productId=@id
    
    exec GetProInfo2 2
  • 相关阅读:
    hibernate4.3.5,Final hibernate.cfg.xml的配置
    mysql 入门 jdbc
    设计模式之责任链
    淘宝技术这十年
    java代码---------计算器实现
    java代码---------打印正三角形
    java代码=====实现修改while()
    java------------break;
    java代码-----循环变量的
    java代码----------实现写出循环
  • 原文地址:https://www.cnblogs.com/ruishuang208/p/3158369.html
Copyright © 2020-2023  润新知