Look at your code:
You open the same connection three times, and only close it if there is an error for the first couple of times.
Instead of grabbing code fragments and trying to bolt them together, you need to start thinking about them, and adapting them to fit your needs.
And in this case, wherever you got the fragments from isn't that good. It is a very good idea to use a
Using
block with MySqlConnections, MySqlCommands, MySqlDataAdapter, and so forth to ensure that they are Closed and Disposed automatically when they go out of scope. This removes the opportunity for you to make mistakes like this.
Using con As New MySqlConnection(strCon)
con.Open()
Using cmd As New MySqlCommand(query, con)
...
End Using
Using cmd2 As New MySqlCommand(query, con)
...
End Using
...
End Using