本文介绍了在datareader和executenonquery中使用相同的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用



I use

MySqlConnection addh = new MySqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);

        addh.Open();

MySqlCommand myCommand = new MySqlCommand(myqry, addh);



然后


and then

MySqlDataReader myDataReader;
        myDataReader = myCommand.ExecuteReader();

if (myDataReader.HasRows)
 {
     while (myDataReader.Read())
     {


foreach(string ede in array)
{
MySqlCommand cmd = new MySqlCommand(amenity, addh);

                        int insert_result = cmd.ExecuteNonQuery();


}



}

myDataReader.Close();

addh.Close();



但我收到错误


But i get error as

C# mySQL There is already an open DataReader associated with this Connection which must be closed first





什么是问题



what is issue

推荐答案


这篇关于在datareader和executenonquery中使用相同的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:36