我有以下代码:
static void InsertRes(string Data)
{
string query = "INSERT INTO results (gamenum,result) " + Data;
query += ";";
//open connection
if (OpenConnection() == true)
{
//create command and assign the query and connection from the constructor
MySqlCommand cmd = new MySqlCommand(query, connection);
//Execute command
cmd.ExecuteNonQuery();
//close connection
CloseConnection();
}
}
我知道这不是最佳实践,但我在我的应用程序中生成数据,如何强制此函数阻塞,直到查询已在 mysql 数据库上成功执行?