Connection must be valid and open error

前端 未结 2 890
误落风尘
误落风尘 2020-12-11 17:48

I\'m getting error: Connection must be valid and open when I start this program. I searched on google and only found 2 people that have the same error. Is it possible to fix

相关标签:
2条回答
  • 2020-12-11 18:14

    You need to tell your command about your connection object. Add the connection parameter to this line:

    MySql.Data.MySqlClient.MySqlCommand myCommand = new MySql.Data.MySqlClient.MySqlCommand(insertQuery, connection);
    
    0 讨论(0)
  • 2020-12-11 18:14

    Your command has no connection assignet to it. Try passing the connection to the the command's constructor like this:

    MySql.Data.MySqlClient.MySqlCommand myCommand = new MySql.Data.MySqlClient.MySqlCommand(insertQuery, connection);
    
    0 讨论(0)
提交回复
热议问题