Created
January 14, 2019 03:13
Setup DataTable with 3 fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataTable table = new DataTable("MyTable"); | |
DataColumn idColumn = new DataColumn("id", typeof(int)); | |
DataColumn amountColumn = new DataColumn("amount", typeof(decimal)); | |
DataColumn dateColumn = new DataColumn("date", typeof(DateTime)); | |
table.Columns.Add(idColumn); | |
table.Columns.Add(amountColumn); | |
table.Columns.Add(dateColumn); | |
DataRow newRow = table.NewRow(); | |
newRow["id"] = 1; | |
newRow["amount"] = 10.3m; | |
newRow["date"] = new DateTime(2018, 10, 20); | |
table.Rows.Add(newRow); | |
newRow = table.NewRow(); | |
newRow["id"] = 2; | |
newRow["amount"] = 42.1m; | |
newRow["date"] = new DateTime(2018, 04, 12); | |
table.Rows.Add(newRow); | |
newRow = table.NewRow(); | |
newRow["id"] = 2; | |
newRow["amount"] = 5.6; | |
newRow["date"] = new DateTime(2018, 07, 2); | |
table.Rows.Add(newRow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment