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
  • 相关阅读:
    Use Study Groups to Support Learning
    “开闭”原则(OpenClosed principle, OCP)
    我的E72i 开发
    conlution of daily work
    appstore相关查询链接
    sqlite3.0不支持的sql属性
    iOS sdk 运行时函数
    自动化测试部分
    ios下获取mac地址修正版
    修改mac os host
  • 原文地址:https://www.cnblogs.com/ruishuang208/p/3158369.html
Copyright © 2011-2022 走看看