Fill gridview using Datareader:
SqlConnection con = new SqlConnection("server=.;database=northwind;integrated security=true");
SqlCommand com = new SqlCommand("select * from Categories", con);
SqlDataReader DR;
con.Open();
DR = com.ExecuteReader(CommandBehavior.CloseConnection);
DR.Read();
GridView1.DataSource = DR;
GridView1.DataBind();
Fill gridview using Datareader:
SqlConnection con = new SqlConnection("server=.;database=northwind;integrated security=true");
SqlDataAdapter DA = new SqlDataAdapter("select * from Categories", con);
DataSet DS = new DataSet();
DA.Fill(DS);
GridView1.DataSource = DS;
GridView1.DataBind();
No comments:
Post a Comment