



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
What ADO.NET DataTable is and how it is used in C#. The DataTable is a central object that represents relational data in tabular form and is stored in memory. how to create an instance of DataTable, define its schema, add rows to it, and iterate through its rows and columns. It also explains how to create primary key columns and DataRow objects. useful for students learning C# and database programming.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!
using System;
dataTable.Columns.Add(Email); //Setting the Primary Key dataTable.PrimaryKey = new DataColumn[] { Id }; //Add New DataRow by creating the DataRow object DataRow row1 = dataTable.NewRow(); row1["Id"] = 101; row1["Name"] = "Anurag"; row1["Email"] = "Anurag@dotnettutorials.net"; dataTable.Rows.Add(row1); //Adding new DataRow by simply adding the values dataTable.Rows.Add(102, "Mohanty", "Mohanty@dotnettutorials.net"); foreach (DataRow row in dataTable.Rows) { Console.WriteLine(row["Id"] + ", " + row["Name"] + ", " + row["Email"]); } } catch (Exception e) { Console.WriteLine("OOPs, something went wrong.\n" + e); } Console.ReadKey(); } } }