zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Java面向对象设计——购物车·
    查找

    栈和队列
    指针
    数组
    第四次博客——函数
    第三次博客作业
    第二次博客作业
    Java购物车大作业01
  • 原文地址:https://www.cnblogs.com/ruishuang208/p/3158369.html
Copyright © 2011-2022 走看看