public void list() { string strCommand = @" select t0.MainCategoryName , t1.SubCategoryId , t1.SubCategoryName from MainCategory t0 Inner join SubCategory t1 ON t0.MainCategoryId = t1.MainCategoryId where t1.Active = 'y'; "; DataTable dt = new DataTable(); Sql sql = new Sql(_strConn); dt = sql.getdt(strCommand); Console.WriteLine(" ---------------------------------------------------- "); Console.WriteLine(" | MainCategoryName | SubCategoryId | SubCategoryName "); Console.WriteLine(" ---------------------------------------------------- "); foreach (DataRow rows in dt.Rows) { Console.Write(" | "); foreach (DataColumn columns in dt.Columns) { Console.Write(rows[columns]); Console.Write(" | "); } Console.Write("\n"); } Console.WriteLine(" ---------------------------------------------------- "); }