string Conn = ConfigurationManager.ConnectionStrings["Connection"].ToString();
SqlConnection con = new SqlConnection(Conn);
SqlCommand cmd1;
SqlCommand cmd2;
SqlDataReader reader1;
SqlDataReader reader2;
try
{
if (!IsPostBack)
{
cmd1 = new SqlCommand("Sp Name", con);
cmd1.CommandType = CommandType.StoredProcedure;
con.Open();
reader1 = cmd1.ExecuteReader();
if (reader1.Read())
{
grd_View.DataSource = reader1;
grd_View.DataBind();
}
if (!reader1.IsClosed)
{
reader1.Close();
}
cmd2 = new SqlCommand("Sp Name", con);
cmd2.CommandType = CommandType.StoredProcedure;
reader2 = cmd2.ExecuteReader();
if (reader2.Read())
{
GridView1.DataSource = reader2;
GridView1.DataBind();
}
if (!reader2.IsClosed)
{
reader2.Close();
}
}
}
catch (Exception)
{
throw;
}
finally
{
con.Close();
}
No comments:
Post a Comment