Wikis > C# Wiki > DataTable
System.Data.DataSet _DataSet = new System.Data.DataSet("MyDataSet");
System.Data.DataRow _DataRow;

System.Data.DataTable _DataTable01 = new System.Data.DataTable();
_DataTable01.Columns.Add(new System.Data.DataColumn("Col_String", Type.GetType("System.String"))); // typeof("string")
_DataTable01.Columns.Add(new System.Data.DataColumn("Col_DateTime", Type.GetType("System.DateTime")));
_DataTable01.Columns.Add(new System.Data.DataColumn("Col_Int32", Type.GetType("System.Int32")));
_DataTable01.Columns.Add(new System.Data.DataColumn("Col_Decimal", Type.GetType("System.Decimal")));

_DataRow = _DataTable01.NewRow();
_DataRow["Col_String"] = "Col_String_01";
_DataRow["Col_Int32"] = 1;
_DataTable01.Rows.Add(_DataRow);

System.Data.DataTable _DataTable02 = new System.Data.DataTable();
_DataTable02.Columns.Add(new System.Data.DataColumn("Col_String", Type.GetType("System.String")));
_DataTable02.Columns.Add(new System.Data.DataColumn("Col_DateTime", Type.GetType("System.DateTime")));
_DataTable02.Columns.Add(new System.Data.DataColumn("Col_Int32", Type.GetType("System.Int32")));
_DataTable02.Columns.Add(new System.Data.DataColumn("Col_Decimal", Type.GetType("System.Decimal")));

_DataRow = _DataTable02.NewRow();
_DataRow["Col_String"] = "Col_String_02";
_DataRow["Col_Int32"] = 2;
_DataTable02.Rows.Add(_DataRow);

_DataTable02.Rows.Add("Col_String_03", System.DateTime.Now(), 99, 12.1);

_DataSet.Tables.Add(_DataTable01);
_DataSet.Tables.Add(_DataTable02);
Category: Tags: