여기에 문제가 있습니다. connection.Open
에서 쿼리 및 그 throw 및 예외를 실행하려고합니다. 이상하게도, 같은 애플리케이션에서 "선택"쿼리를 실행 중이며 정상적으로 작동합니다. 하지만 "업데이트"쿼리를 실행하면이 Unable이 지정된 MySQL 호스트 오류에 연결됩니다. 이걸 영원히 붙잡 았어. 누군가 내가 잘못 가고있는 곳을 찾을 수 있습니까?지정한 MySQL 호스트 중 하나에 연결할 수 없습니다.
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
timerEnabled = 1;
}
connection.Open();
//update the settings to the database table
MySqlCommand command = connection.CreateCommand();
command.CommandText = "update Admin_Settings set Difficulty='" + comboBox3.Text + "'," + "NoOfQuestions='" + comboBox4.Text + "'," + "NoOfChoices='" + comboBox5.Text + "'," +
"Subject='" + comboBox8.Text + "'," + "Timer='" + comboBox2.Text + "," + "TimerEnabled=" + timerEnabled + "," + "TimerType='" + comboBox1.Text + "'";
command.ExecuteNonQuery();
MessageBox.Show("Settings updated");
}
귀하의 질문은 더 많은 정보를 필요로보십시오. 'connection.Open();'이 실행될 때 연결이 이미 열려 있습니까? 가능한 원인처럼 보입니다. – evanmcdonnal