zoukankan      html  css  js  c++  java
  • ADO:DataSet合并两张表( ds.Merge(ds1))

    原文发布时间为:2008-08-01 —— 来源于本人的百度文章 [由搬家工具导入]

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;


    using System.Data.SqlClient;

    public partial class dataset2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["pubsConn"].ConnectionString);
            SqlDataAdapter sda = new SqlDataAdapter();
            sda.SelectCommand = new SqlCommand("select title_id,title,type from titles", conn);
            DataSet ds = new DataSet();
            sda.Fill(ds, "t1");

            UniqueConstraint uc = new UniqueConstraint("pk", ds.Tables["t1"].Columns["title_id"], true);
            ds.Tables["t1"].Constraints.Add(uc);//表必须设主键,不然会直接合并到表的下面

            DataSet ds1 = new DataSet();
            sda.SelectCommand=new SqlCommand("select title_id,ord_num from sales",conn);
            sda.Fill(ds1,"t1");

           Session["ds"]=ds;
            Session["ds1"]=ds1;

            GridView1.DataSource=ds.Tables["t1"];
            GridView1.DataBind();
        
            GridView2.DataSource=ds1.Tables["t1"];
            GridView2.DataBind();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataSet ds = (DataSet)Session["ds"];
            DataSet ds1 = (DataSet)Session["ds1"];

           ds.Merge(ds1);//合并

            GridView3.DataSource = ds.Tables["t1"];
            GridView3.DataBind();       
        }
    }

  • 相关阅读:
    FCOS及其和Faster R-CNN的区别
    CornerNet: Detecting Objects as Paired Keypoints
    神经网络不收敛的原因
    交叉熵损失函数
    Placeholder_2:0 is both fed and fetched
    使用Lambda解决_inbound_nodes错误
    Python对Dict排序
    对Faster R-CNN的理解(3)
    Keras运行速度越来越慢的问题
    深度卷积网络(DCNN)和人类识别物体方法的不同
  • 原文地址:https://www.cnblogs.com/handboy/p/7141576.html
Copyright © 2011-2022 走看看