主要是想实现一个DataTable获取信息列表,一个DataTable获取数据统计protected DataSet GetDataSource()
        {
            DataSet ds = new DataSet();
            ds.Tables.Add(AccessHelper.ExecuteTable("select * from [UserInfo]").Copy());
            ds.Tables.Add(AccessHelper.ExecuteTable("select Count(*) from [UserInfo]").Copy());
            return ds;
        }
这样的代码提示:名为“Result”的 DataTable 已属于此 DataSet。 
错误指向:ds.Tables.Add(AccessHelper.ExecuteTable("select Count(*) from [UserInfo]").Copy());

解决方案 »

  1.   

    換個名字吧,第二個datatable指定個名字
      

  2.   

    private void AddDataTable()
    {
        // Get the DataTableCollection of a DataGrid 
        // control's DataSet.
        DataTableCollection tables = 
            ((DataSet)DataGrid1.DataSource).Tables;    // Create a new DataTable.
        DataTable table = new DataTable();    // Code to add columns and rows not shown here.    // Add the table to the DataTableCollection.
        tables.Add(table);
    }