怎样向DATAGRID里添加数据啊?而不是覆盖原有数据...
我现在是this.DGDetail.DataSource = dsBook.Tables[0];
但如果再来个this.DGDetail.DataSource = dsBook.Tables[1];我怎么将它加进去啊?谢谢各位了!!!
我现在是this.DGDetail.DataSource = dsBook.Tables[0];
但如果再来个this.DGDetail.DataSource = dsBook.Tables[1];我怎么将它加进去啊?谢谢各位了!!!
解决方案 »
- treelist的checkedit列格式怎么控制
- C#开发WPF/Silverlight动画及游戏系列教程(Game Tutorial)献给大家
- C# 怎么下载隐藏资源?同时告诉新人怎么实现webbrowser的点击操作,有代码有真相
- 如何让日历控件从数据库读取日期并显示!?
- 自定义TextBox的OnPaint后,为何他的高度变小了
- 刚申请了个QQ群,希望作为编程技术讨论群,高手请加入!
- C#winform (TCP)socket异步是不能不能实现多个文件的同时接受
- 请高手看看我这个登陆代码是不是对的,感谢
- 问题
- 点击TreeView中某一项(NODE)时,触发哪些事件需要处理呢
- 一个关于UML表示的例子
- 怎样可以模拟鼠标在窗口的头部按下后可以移动窗口(WINFORM)???
for(int i = 0; i<intCountRows; i++)
{
String strSelect ="select CUSTID,CUSTNM,ADDR1,TEL from CUST_MST where CUSTID in " +
"(select distinct a.CUSTID from (select CUSTID from
KKSDB.dbo.URIMEIDTL_TBL where BOOKID = " + "'" + this.txtNumber.Text.PadLeft(6,'0') + "' )as a" + " where a.CUSTID not in (select CUSTID from KKSDB.dbo.SRCSAV_TBL where BOOKID = " + "'" + this.txtNumber.Text.PadLeft(6,'0') + "'))"
+ "and CUSTID in (select CUSTID from KKSDB.dbo.SRCSAV_TBL where BOOKID = 'strArray[i]')";
DataSet dsBook = dbConn.selGetDataSet(strSelect);this.DGDetail.DataSource = dsBook.Tables[0];}
例﹕
private void DemonstrateMergeTableAddSchema(){
// Create a DataSet with one table, two columns, and ten rows.
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;
newRow["extra"]= "extra Column 1";
t2.Rows.Add(newRow); newRow=t2.NewRow();
newRow["id"]= 13;
newRow["Item"]=665;
newRow["extra"]= "extra Column 2";
t2.Rows.Add(newRow); // Merge the table into the DataSet.
Console.WriteLine("Merging");
ds.Merge(t2,false,MissingSchemaAction.Add);
PrintValues(ds, "Merged With Table, Schema Added");
}private void Row_Changed(object sender, DataRowChangeEventArgs e){
Console.WriteLine("Row Changed " + e.Action.ToString() + "\t" + e.Row.ItemArray[0]);
}private void PrintValues(DataSet ds, string label){
Console.WriteLine("\n" + label);
foreach(DataTable t in ds.Tables){
Console.WriteLine("TableName: " + t.TableName);
foreach(DataRow r in t.Rows){
foreach(DataColumn c in t.Columns){
Console.Write("\t " + r[c] );
}
Console.WriteLine();
}
}
}說明:
.NET Framework 类库 DataSet.Merge 方法
将指定的 DataSet、DataTable 或 DataRow 对象的数组合并到当前的 DataSet 或 DataTable 中。重载列表
将 DataRow 对象数组合并到当前的 DataSet 中。[Visual Basic] Overloads Public Sub Merge(DataRow())
[C#] public void Merge(DataRow[]);
[C++] public: void Merge(DataRow*[]);
[JScript] public function Merge(DataRow[]);
将指定的 DataSet 及其架构合并到当前 DataSet 中。[Visual Basic] Overloads Public Sub Merge(DataSet)
[C#] public void Merge(DataSet);
[C++] public: void Merge(DataSet*);
[JScript] public function Merge(DataSet);
将指定的 DataTable 及其架构合并到当前 DataSet 中。[Visual Basic] Overloads Public Sub Merge(DataTable)
[C#] public void Merge(DataTable);
[C++] public: void Merge(DataTable*);
[JScript] public function Merge(DataTable);
将指定的 DataSet 及其架构合并到当前 DataSet 中,在此过程中,将根据给定的参数保留或放弃在此 DataSet 中进行的任何更改。[Visual Basic] Overloads Public Sub Merge(DataSet, Boolean)
[C#] public void Merge(DataSet, bool);
[C++] public: void Merge(DataSet*, bool);
[JScript] public function Merge(DataSet, Boolean);
将 DataRow 对象数组合并到当前的 DataSet 中,在此过程中,将根据给定的参数保留或放弃在 DataSet 中进行的更改并处理不兼容的架构。[Visual Basic] Overloads Public Sub Merge(DataRow(), Boolean, MissingSchemaAction)
[C#] public void Merge(DataRow[], bool, MissingSchemaAction);
[C++] public: void Merge(DataRow*[], bool, MissingSchemaAction);
[JScript] public function Merge(DataRow[], Boolean, MissingSchemaAction);
将指定的 DataSet 及其架构与当前的 DataSet 合并,在此过程中,将根据给定的参数保留或放弃在当前 DataSet 中的更改并处理不兼容的架构。[Visual Basic] Overloads Public Sub Merge(DataSet, Boolean, MissingSchemaAction)
[C#] public void Merge(DataSet, bool, MissingSchemaAction);
[C++] public: void Merge(DataSet*, bool, MissingSchemaAction);
[JScript] public function Merge(DataSet, Boolean, MissingSchemaAction);
将指定的 DataTable 及其架构合并到当前的 DataSet 中,在此过程中,将根据给定的参数保留或放弃在 DataSet 中进行的更改并处理不兼容的架构。[Visual Basic] Overloads Public Sub Merge(DataTable, Boolean, MissingSchemaAction)
[C#] public void Merge(DataTable, bool, MissingSchemaAction);
[C++] public: void Merge(DataTable*, bool, MissingSchemaAction);
[JScript] public function Merge(DataTable, Boolean, MissingSchemaAction);