Linq- dataset - select - many columns
I came across a situation using data set i have to select mutiple columns using Linq
Here is my code
cn.Open();
SqlCommand cmd = new SqlCommand("Spname", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ParameterName", value);
cmd.Parameters.AddWithValue("parametername", value);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
grddataset.DataSource = from t in ds.DataRecordSet()// we need to extend dataset as it does not implement ienumerable
select new {DataSetEmail = ds.Tables[0].Rows[0][4].ToString(), DataSetFirstName = ds.Tables[0].Rows[0][2].ToString(), LastName = ds.Tables[0].Rows[0][3].ToString() };
grddataset.DataBind();
cn.Close();
da.Dispose();
Implementation of Ienumerable for data set
public static class DataSetExtension
{
public static IEnumerable
Here is my code
cn.Open();
SqlCommand cmd = new SqlCommand("Spname", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ParameterName", value);
cmd.Parameters.AddWithValue("parametername", value);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
grddataset.DataSource = from t in ds.DataRecordSet()// we need to extend dataset as it does not implement ienumerable
select new {DataSetEmail = ds.Tables[0].Rows[0][4].ToString(), DataSetFirstName = ds.Tables[0].Rows[0][2].ToString(), LastName = ds.Tables[0].Rows[0][3].ToString() };
grddataset.DataBind();
cn.Close();
da.Dispose();
Implementation of Ienumerable for data set
public static class DataSetExtension
{
public static IEnumerable