Abhilash J A

Abhilash J A

  • 531
  • 2.4k
  • 600.1k

Select query for retrieve data from temporary DataTable?

Jul 5 2016 4:59 AM
Sir,
 
How can I write this inline sql (That is,cmdstr) query to datarow c#?
 
string cmdstr = "select top 5 First_name, COUNT(Department) [Department] from Employee group by First_name"; 
 
 DataTable dt = new DataTable("Employee");
dt.Columns.Add(new DataColumn("Id", typeof(int)));
dt.Columns.Add(new DataColumn("First_name", typeof(string)));
dt.Columns.Add(new DataColumn("Department", typeof(int)));

dt.Rows.Add(1, "Jerry", 1);
dt.Rows.Add(2, "Mudassar", 1);
dt.Rows.Add(3, "Mathews", 1);
dt.Rows.Add(4, "Robert", 1);
dt.Rows.Add(5, "John", 1);
 
 
DataRow[] result =?

Answers (2)