为什么不用DataSet之间赋值呢?

解决方案 »

  1.   

    System.Data.DataTable table;
    table = new System.Data.DataTable("table");
    table.Reset(); //共3列
    System.Data.DataColumn col = new System.Data.DataColumn("项目", System.Type.GetType("System.String"));
    table.Columns.Add(col); col = new System.Data.DataColumn("数字", System.Type.GetType("System.Int32"));
    table.Columns.Add(col); col = new System.Data.DataColumn("比较计划", System.Type.GetType("System.Int32"));
    table.Columns.Add(col); //共5行
    System.Data.DataRow row = table.NewRow();
    row["项目"] = "现在车";
    table.Rows.Add(row); row = table.NewRow();
    row["项目"] = "运用车";
    table.Rows.Add(row); row = table.NewRow();
    row["项目"] = "重车";
    table.Rows.Add(row); row = table.NewRow();
    row["项目"] = "空车";
    table.Rows.Add(row); row = table.NewRow();
    row["项目"] = "非运用车";
    table.Rows.Add(row);
    DataSet dataSet = new DataSet();
    dataSet.Tables.Add(table);
      

  2.   

    table.Rows[0]["数字"] = node.Attributes.GetNamedItem("nowFreight").Value;
    table.Rows[1]["数字"] = node.Attributes.GetNamedItem("useFreight").Value;
    table.Rows[2]["数字"] = node.Attributes.GetNamedItem("havingFreight").Value;
    table.Rows[3]["数字"] = node.Attributes.GetNamedItem("voidFreight").Value;
    table.Rows[4]["数字"] = node.Attributes.GetNamedItem("unUseFreight").Value;忘记了!^_^
      

  3.   

    StringReader sr = new StringReader(myPrintControl.XmlString);
    this.ds1.ReadXml(sr);注意:(1)_用GetXml得到的XmlString再生成DataSet的时候有时候容易串,是因为原DataSet中有的字段值为null.
         (2)新的DataTable里所有Column的DataType都是String.    
      

  4.   

    If you call ReadXml to load a very large file, you may encounter slow performance. To ensure best performance for ReadXml, on a large file, call the DataTable.BeginLoadData method for each table in the DataSet, then call ReadXml. Finally, call DataTable.EndLoadData for each table in the DataSet as shown in the following example.
    foreach (DataTable t in ds.Tables)
      t.BeginLoadData();ds.ReadXml("file.xml"); foreach (DataTable t in ds.Tables)
      t.EndLoadData();