Http://blog.csdn.net/diyoosjtu/article/details/7585111
[CSHARP]
View plaincopyprint?
- Datatable dt = new datatable ("cart ");
- Datacolumn DC1 = new datacolumn ("prizename", type. GetType ("system. String "));
- Datacolumn DC2 = new datacolumn ("point", type. GetType ("system. int16 "));
- Datacolumn DC3 = new datacolumn ("Number", type. GetType ("system. int16 "));
- Datacolumn dc4 = new datacolumn ("totalpoint", type. GetType ("system. int64 "));
- Datacolumn dC5 = new datacolumn ("prizeid", type. GetType ("system. String "));
- DT. Columns. Add (DC1 );
- DT. Columns. Add (DC2 );
- DT. Columns. Add (DC3 );
- DT. Columns. Add (dc4 );
- DT. Columns. Add (dC5 );
- // The above code completes the datatable architecture, but there is no data in it
- For (INT I = 0; I <10; I ++)
- {
- Datarow DR = DT. newrow ();
- Dr ["prizename"] = "doll ";
- Dr ["point"] = 10;
- Dr ["Number"] = 1;
- Dr ["totalpoint"] = 10;
- Dr ["prizeid"] = "001 ";
- DT. Rows. Add (DR );
- }
- // Fill in 10 identical records
- Someone will do this.
- Datarow DR = new datarow ();
- ..
- DT. Rows. Add (DR );
- This is not acceptable, because a datarow must belong to a datatable and cannot be created out of thin air, just as a record must belong to a table.
- Someone else does this.
- Datarow DR = DT. newrow ();
- Dr ["prizename"] = "doll ";
- Dr ["point"] = 10;
- Dr ["Number"] = 1;
- Dr ["totalpoint"] = 10;
- Dr ["prizeid"] = "001 ";
- For (INT I = 0; I <10; I ++)
- {
- DT. Rows. Add (DR );
- }
- This is also wrong, because the datatable already has this datarow, it is like a table that cannot have two identical records, each time newrow ()
[CSHARP]
View plaincopyprint?
- Datatable dt = new datatable ("cart ");
- Datacolumn DC1 = new datacolumn ("prizename", type. GetType ("system. String "));
- Datacolumn DC2 = new datacolumn ("point", type. GetType ("system. int16 "));
- Datacolumn DC3 = new datacolumn ("Number", type. GetType ("system. int16 "));
- Datacolumn dc4 = new datacolumn ("totalpoint", type. GetType ("system. int64 "));
- Datacolumn dC5 = new datacolumn ("prizeid", type. GetType ("system. String "));
- DT. Columns. Add (DC1 );
- DT. Columns. Add (DC2 );
- DT. Columns. Add (DC3 );
- DT. Columns. Add (dc4 );
- DT. Columns. Add (dC5 );
- // The above code completes the datatable architecture, but there is no data in it
- For (INT I = 0; I <10; I ++)
- {
- Datarow DR = DT. newrow ();
- Dr ["prizename"] = "doll ";
- Dr ["point"] = 10;
- Dr ["Number"] = 1;
- Dr ["totalpoint"] = 10;
- Dr ["prizeid"] = "001 ";
- DT. Rows. Add (DR );
- }
- // Fill in 10 identical records
- Someone will do this.
- Datarow DR = new datarow ();
- ..
- DT. Rows. Add (DR );
- This is not acceptable, because a datarow must belong to a datatable and cannot be created out of thin air, just as a record must belong to a table.
- Someone else does this.
- Datarow DR = DT. newrow ();
- Dr ["prizename"] = "doll ";
- Dr ["point"] = 10;
- Dr ["Number"] = 1;
- Dr ["totalpoint"] = 10;
- Dr ["prizeid"] = "001 ";
- For (INT I = 0; I <10; I ++)
- {
- DT. Rows. Add (DR );
- }
- This is also wrong, because the datatable already has this datarow, it is like a table that cannot have two identical records, each time newrow ()