Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

DataReader associated with this connection must be closed first (no replies)

$
0
0
I keep getting this error message: DataReader associated with this connection must be closed first. Here's an example of the code I'm running:


MySqlConnection conn = new MySqlConnection(conString);
MySqlCommand cmd  = new MysqlCommand();
conn.Open();
cmd.Connection = conn;

public void Insert(string name)
{
  cmd.CommandText = String.Format("Insert Into tbl (id,name) Values (Null,'{0}')", name);
  cmd.ExecuteNonQuery();
}


public void Update(string name)
{
  cmd.CommandText = String.Format("Update Into tbl_2 Set name = '{0}'", name);
  cmd.ExecuteNonQuery();
}

these methods are being executed approximated 2 or 3 times per second and I have them running on separate threads.

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>