如题,不想用把Table2中的行一条一条的加到Table1中地加那种方式.
有没有别的方法?
有没有别的方法?
解决方案 »
- 求助!!
- asp。net如何判断下载完成或失败
- 客户端上传文件至数据库
- 请问这样的方法生成的ID是绝对唯一的吗?
- asp.net怎么不保存上传的XML格式文件 直接读取文件?
- 关于javascript不以asp.net交服的问题
- 怎么让父窗口在弹出的子窗口关闭后,自动刷新一次?--答案通过,马上结贴!!!
- 动态生成的DropDownList控件,是否可以重复使用。(在线等)
- 如何将一个DataTable里的数据倒入ADO中的RecordSet?
- 初学者!DataGrid在C#中的分页问题!
- 怎么在已经添加好所有节点树里面再添加一个顶层的父节点(在线等)
- 怎样在.aspx中自己任意输出数据库中的数据
DataSet ds = new DataSet("myDataSet");
DataTable t = new DataTable("Items"); // Add table to the DataSet
ds.Tables.Add(t); // Create and add two columns to the DataTable
DataColumn c1 = new DataColumn("id", Type.GetType("System.Int32"),"");
c1.AutoIncrement=true;
DataColumn c2 = new DataColumn("Item", Type.GetType("System.Int32"),"");
t.Columns.Add(c1);
t.Columns.Add(c2); // Set the primary key to the first column.
t.PrimaryKey = new DataColumn[1]{ c1 }; // Add RowChanged event handler for the table.
t.RowChanged+= new DataRowChangeEventHandler(Row_Changed); // Add ten rows.
for(int i = 0; i <10;i++){
DataRow r=t.NewRow();
r["Item"]= i;
t.Rows.Add(r);
} // Accept changes.
ds.AcceptChanges();
PrintValues(ds, "Original values"); // Create a second DataTable identical to the first, with
// one extra column using the Clone method.
DataTable t2 = t.Clone();
t2.Columns.Add("extra", typeof(string)); // Add two rows. Note that the id column can't be the
// same as existing rows in the DataSet table.
DataRow newRow;
newRow=t2.NewRow();
newRow["id"]= 12;
newRow["Item"]=555;
t2.Rows.Add(newRow); newRow=t2.NewRow();
newRow["id"]= 13;
newRow["Item"]=665;
t2.Rows.Add(newRow); // Merge the table into the DataSet.
ds.Merge(t2,false,MissingSchemaAction.Add);