Problems: 1: The Read method cannot be called when another read operation is pending. 2: There is already an open DataReader associated with this Connection which must be closed first.
I have used Asp.net c# and MySql to develop my project. When I did publish it, I faced a problem. The problem is when more than one user open the website, the MySql connection stop working. There is a sample of my code.
public partial class ConTest : System.Web.UI.Page
{
MySqlConnection con = new MySqlConnection("Server= mysql-85112-0.cloudclusters.net; port=11923; Database=Test; Uid=xxxx; Pwd=xxxx;");
MySqlCommand cmd = new MySqlCommand();
MySqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
cmd.Connection = con;
Database.con.Close();
Database.con.Open();
cmd.CommandText = "select s_name from students_info";
dr = cmd.ExecuteReader();
while (dr.Read())
{
Label1.Text = dr[0].ToString();
}
Database.con.Close();
}
}