Currently I have code which looks up a database table through a SQL connection and inserts the top five rows into a Datatable (Table).
using(SqlCommand _cmd
This is done by data table that holds single table
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("select * from info", con);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
ad.Fill(dt);
Console.WriteLine(dt.Columns[0].ColumnName.ToString());
Console.WriteLine(dt.Rows[1].ItemArray[0].ToString());
This is done by data set that holds set of table
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("select * from info", con);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataSet dt = new DataSet();
ad.Fill(dt);
Console.WriteLine(dt.Tables[0].Columns[0].ColumnName.ToString());
Console.WriteLine(dt.Tables[0].Rows[0].ItemArray[0].ToString());
both will give same result. only data set contains number of index of table.