Unable to resolve this error[There is already an open DataReader associated with this Command which must be closed first]

There is already an open DataReader associated with this Command which must be closed first......
Please help.....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Net.Mail;
using System.Net;

namespace housing1
    public partial class admin_action : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

            if (!IsPostBack)
                HiddenFieldS2.Value = "Updated";
                HiddenFieldS1.Value = "Pending";
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HousingConnectionString"].ConnectionString);
                SqlDataAdapter da = new SqlDataAdapter("Select Flat from User_Complain where Status='"+HiddenFieldS1.Value+"'", conn);
                DataTable dt = new DataTable();
                DropDownListFN.DataSource = dt;
                DropDownListFN.DataTextField = "Flat";



        protected void Button2_Click(object sender, EventArgs e)
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HousingConnectionString"].ConnectionString);

            String str = "select Complain_Name ,Description from User_Complain where Flat='" + DropDownListFN.Text.Trim() + "' and Complain_Id='"+TextBoxID.Text+"'";
            SqlCommand comm = new SqlCommand(str, conn);
            SqlDataReader reader = comm.ExecuteReader();
            if (reader.Read())
                TextBoxTOP.Text = reader["Complain_Name"].ToString();
                TextBoxD.Text = reader["Description"].ToString();
               // HiddenFieldM.Value=reader[""]

            String str1 = "select Email from Primary_Member where Flat='" + DropDownListFN.Text.Trim() + "'";
            SqlCommand comm1 = new SqlCommand(str1, conn);
            SqlDataReader reader1 = comm1.ExecuteReader();
            if (reader1.Read())

                HiddenFieldM.Value = reader1["Email"].ToString();

        protected void Button1_Click(object sender, EventArgs e)

                var messagefrom = "nidhi@indweb.com";
                var toAddress = HiddenFieldM.Value;
                string messageBody = TextBoxAT.Text;
                string fromPassword = "nid100";
                var subject = "Subject";
                var client = new SmtpClient
                    Host = "smtp.gmail.com",
                    Port = 587,
                    EnableSsl = true,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials = new NetworkCredential(messagefrom, fromPassword)

                using (var msg = new MailMessage(messagefrom, toAddress)
                    Subject = subject,
                    Body = messageBody
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HousingConnectionString"].ConnectionString);
                String insertQuery1 = "insert into Admin_Action ( Flat ,Complain_Name , Description, Action_Performed , Status) values(  @flat , @cname , @des ,@action , @status)";
                SqlCommand com = new SqlCommand(insertQuery1, conn);
                com.Parameters.AddWithValue("@cname", TextBoxTOP.Text);
                com.Parameters.AddWithValue("@flat", DropDownListFN.SelectedValue);
                com.Parameters.AddWithValue("@des", TextBoxD.Text);
                com.Parameters.AddWithValue("@action", TextBoxAT.Text);
                com.Parameters.AddWithValue("@status", "");

                String updateQuery = "update User_Complain set  Status= '" + HiddenFieldS2.Value + "' where Flat='" + DropDownListFN.SelectedValue + "'";
                SqlCommand com1 = new SqlCommand(updateQuery, conn);
                Response.Write("mail send");

            catch (Exception ex)



Open in new window

Sukesh ShuklaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Naitik GamitSoftware DeveloperCommented:
Set MultipleActiveResultSets=True in web.config will solve your problem.

You can also try to create second connection to same database maybe solves the problem.
Éric MoreauSenior .Net ConsultantCommented:
Yes MARS is the solution. Check http://emoreau.com/Entries/Articles/2006/11/MARS-and-Asynchronous-ADONet.aspx for more details.
Gary DavisDir Internet SvcsCommented:
Put the Close() call outside the "if" block.
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Sukesh ShuklaAuthor Commented:
where exactly do we write MultipleActiveResultSets=True in web.config file
Éric MoreauSenior .Net ConsultantCommented:
it is an attribute of your database connection string
Naitik GamitSoftware DeveloperCommented:
In web.config you can add MultipleActiveResultSets=True in connection string.

Look at this link for example:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.