Im receiving the above msg even after using MultipleActiveResultSets=True to connection string
public partial class registration : System.Web.UI.UserControl
{
string gender;
SqlCommand cmd = null;
SqlConnection con = null;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection("Server=.; database=nkm; user id=sa; pwd=karthavya");
con.Open();
cmd = new SqlCommand();
cmd.Connection = con;
int years = DateTime.Now.Year;
int i = 1;
while (i < 32)
{
ListItem L = new ListItem(i.ToString(), i.ToString());
days.Items.Add(L);
i++;
}
for (i = 1; i < 13; i++)
{
ListItem L = new ListItem(i.ToString(), i.ToString());
month.Items.Add(L);
}
for (i = 1950; i <= years; i++)
{
ListItem L = new ListItem(i.ToString(), i.ToString());
year.Items.Add(L);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if(RadioButton1.Checked)
gender="Male";
else if(RadioButton2.Checked)
gender="Female";
cmd.CommandText = string.Format("SELECT uid FROM member WHERE uid='{0}'", txtuserid.Text);
SqlDataReader buffer = cmd.ExecuteReader();
if (buffer.Read())
{
Response.Write("<script> alert('User Id already exist " + buffer.GetValue(1).ToString() + " ...') </script>");
buffer.Close();
}
else
{
cmd.CommandText = "member_login";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@uid", txtuserid.Text);
cmd.Parameters.AddWithValue("@password", txtpassword.Text);
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@fname", txtfname.Text);
cmd.Parameters.AddWithValue("@gender", gender);
cmd.Parameters.AddWithValue("@dob", string.Concat(month.SelectedItem.Value, "/", days.SelectedItem.Value, "/", year.SelectedItem.Value));
cmd.Parameters.AddWithValue("@bgroup", bgroup.SelectedItem.Value);
cmd.Parameters.AddWithValue("@address1", txtaddress1.Text);
cmd.Parameters.AddWithValue("@address2", txtaddress2.Text);
cmd.Parameters.AddWithValue("@city", txtcity.Text);
cmd.Parameters.AddWithValue("@district", txtdistrict.Text);
cmd.Parameters.AddWithValue("@state", txtstate.Text);
cmd.Parameters.AddWithValue("@pincode", txtpincode.Text);
cmd.Parameters.AddWithValue("@email", txtemail.Text);
cmd.Parameters.AddWithValue("@phone", txtphone.Text);
cmd.Parameters.AddWithValue("@mobile", txtmobile.Text);
cmd.Parameters.AddWithValue("@nominee_name", txtnomineename.Text);
cmd.Parameters.AddWithValue("@nominee_address", txtnomineeaddress.Text);
cmd.Parameters.AddWithValue("@nominee_relationship", txtnomineerealtionship.Text);
cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("MM/dd/yyyy"));
cmd.Parameters.AddWithValue("@session", "Null");
cmd.Parameters.AddWithValue("@flag", 0);
cmd.Parameters.AddWithValue("@status", "0");
Label1.Text = " Record added successully";
cmd.ExecuteNonQuery();
}
con.Close();
}
}
Please help me regarding this, since two days i hang up here only
pls pls psls