Connection must be valid and open error

前端 未结 2 925
误落风尘
误落风尘 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

    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);
    

提交回复
热议问题